Go to the Deploy & Run Transactions tab within the Remix IDE
This is an example of what your Deploy & Run Transactions should look like
You want to make sure you select the TokenShop.sol Contract (not the TokenInterface called TokenShop.sol) from the contract field in the deployment tab. You will receive an error if you choose the TokenShop's Interface file.
IMPORTANT: SELECT THE TOKENSHOP
After it's deployed to Sepolia, and you see the transaction details in Remix's console sub-window, copy your Token.sol Contract address from the Deployed Contracts UI in Remix
Example of how to copy your Token.sol Contract address
Paste your Token.sol Contract (which you deployed in the previous section) address as the TOKENADDRESS deployment parameter in the deploy tab
Example of token address being included in TokenShop.sol for Deployment
Confirm your transaction in Metamask
Example MetaMask Transaction Confirmation
Giving Token Shop Token-minting rights
On the Token.Sol dropdown in the deployed contracts section, you are looking for the MINTER_ROLE property. Click it to read the data from your smart contract. It should be “0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6”
For your knowledge it is the hash of the word “MINTER_ROLE”
MINTER_ROLE Call
Next, you are going to run paste that MINTER_ROLE hash string into the grantRole() function along with the TokenShop Address:
role: 0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6account: "Your tokenshop address"
Example of grantRole
This is an example of how to copy your TokenShop Contract Address for the account: parameter in last image
Doing this will authorize your TokenShop to mint your newly created token.
We will now double-check and confirm that your TokenShop has indeed been authorized
In your Token.sol Dropdown menu you will want to find the hasRole function. You will open this up and see that it requires two parameters. These are as follows
role: 0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6account: "your TokenShop address"
Example of the hasRole call with fields inputted
We are expecting a boolean response of true
Example of completed confirmation of authorization
Getting Price Data from Chainlink Price Feeds
Now we are going to use the Chainlink USD/ETH price feed that we have referenced inside our TokenShop Contract.
Go to your TokenShop.sol deployed contract dropdown and find the getChainlinkDataFeedLatestAnswer() function. You can hover your mouse over the buttons to see the full name : it should show something like this
Example of getChainlinkDataFeedLatestAnswer
This is an example of a return value from clicking the getChainlinkDataFeedLatestAnswer
Notice the integer returned is quite large, that is because solidity does handle decimal points. Note that you need to know how many decimal points a given feed has. You can find this data in the Price Feeds Documentation (make sure "Show More Details" is checked)
The integer we got back needs to be converted. Since the ETH/USD price feed's data has 8 decimal places, we can see that the price as per the screenshot is $3125.42553378 (divide the returned value by 10^8 to add the decimals back in).
Buying tokens on metamask
Open your Metamask and send 0.01 ETH to your TokenShop.sol Address
The address at the top and beginning with 0xD1 is my TokenShop.sol Address, The amount I chose was .01 ETH
Confirm the transaction
You can check your wallet's token balance on Metamask & through Remix IDE in the Token.sol Deployed Contracts UI.
What it looks like in my imported Tokens list in Metamask
Using REMIX IDE - balanceOf call in the Token.sol dropdown menu
Token Shop Exercise - In this exercise we will be creating the TokenShop.sol Contract where other people will be able to buy our newly created token.