The Week 1 [NFT-Tutorial] (https://github.com/BlockDevsUnited/NFT-Tutorial) can be completed entirely in Remix IDE. This mini tutorial will guide you how to do it.
-
Open Remix IDE in Web Browser
-
Add a workspace and name it "Week 1"
-
Delete all files and folders except for empty contracts folder.
-
Review the Remix documentation about File Explorer in Remix IDE.
In the contracts folder create a new file NFTee.sol and add the code from the sample contract NFTee.sol in this repo.
Review Compiler (Solidity) documentation for Remix IDE.
These are the steps to compile the contract:
-
Open the cobtract by clicking on the file in Remix IDE
-
Select
Compile
tab from the left menu in Remix IDE. This opens compiler settings. -
Set up the following compiler settings:
COMPILER: Select compiler version that matches "pragma solidity" line in your contract code; LANGUAGE: Solidity; EVM VERSION: Compiler default; COMPILER CONFIGURATION: Leave all boxes unchecked;
-
Click on Compile button
Any error or warnings will appear under the Compiler button. Scroll down to see them.
When the compilation is successful:
- A green check mark shows on the compiler tab in the left menu.
- The Compilation Details button under Compile button will become active. Make sure that you select your contract if you would like to check its compilation details.
Review Deploy and Run section in Remix IDE documentation.
Use JavaScript VM environment to deploy and run the contract in a sandbox blockchain in your browser.
Select your cobtract from the CONTRACT drop down menu and click on deploy.
When the contract deploys successfully, the "Deployed Contracts" area controls become active. Next you will use them to interact with your contract.
Review Run and Deploy (part 2) section in Remix IDE documentation.
The last section in the Run tab contains a list of deployed contracts to interact with through autogenerated UI of the deployed contract (also called udapp).
Select your contract. Then run the functions in your contract by clicking on the autogenerated buttons in the udapp. Watch the Remix IDE console for output.
If the contract function requires input parameters, specify them in the fields under the function buttons in udapp.
Use Injected Provider environment to deploy on Rinkeby Testnet.
When you click deploy, you will be prompted to connect with injected web3 provider.
- make sure you get some rinkeby testnet Ether. You can get some here: https://faucet.rinkeby.io/
- set up a injected web3 provider, such as metamask, with Rinkeby Testnet
The transaction information will be printed in the Remix IDE console after deployment success. Identify the transaction hash because you will need it to find the contract on etherscan.
- Open https://rinkeby.etherscan.io/
- Search for the transaction hash for the contrat deployment transaction in the previous section
- In the search output, the
To:
field contains the contract address. Note your contract address. - Click on the link with the contract address to open your contract in etherscan. You should see something like https://rinkeby.etherscan.io/address/0x...
- Click on the tab "Contract" (you can find it to the left of the "Transactions" tab)
- Click on the link for "Verify and Publish" and the form to verify and publish will open. The URL should look something like https://rinkeby.etherscan.io/verifyContract?a=0x...
On page 1 of the form, you will need to select Solity(Single File) for Compiler Type. Fill in the rest of the settings and click continue.
On page 2 of the form, you will need the flattened source code of your contract. Here are the steps to generate it.
- Open your contract in Remix IDE
- Right click on your contract file in the Remix IDE File broser and select "Flatten"
- The flatten operation generates a single file NFTee_flat.sol at the top level of your workspace in Remix IDE.
- Open the NFTee_flat.sol file in Remix IDE and compile it. If there are compilation errors, fix them. Generally, we encountered two types of errors:
- A line
// SPDX-License-Identifier: MIT
is needed at the top of the flattened file - Objects in Solidity need to be defined before they can be used. Move their definitions towards the beginning of the flattened file.
- When the flattened file compiles without errors in Remis IDE, you are ready to copy it in the Etherscan verification form
After you verify and publish your contract on Etherscan, you will be able to use etherscan to interact with your contract.
- Open your contract address in etherscan. The URL will be like https://rinkeby.etherscan.io/address/0x...
- Click on the
Contract
tab at the middle of the page. - Click on
Write Contract
button. - You will see autogenerated UI to interact with the functions in your contract
Remix IDE does not provide persistant file storage. We will use GitHub gist to save our work between work sessions in Remix IDE.
- In Remix IDE click on the button "Publish all current workspace files (root only) to a github gist"
- You will be prompted to login to github.com if you are not already logged in.
Upon successful execution, you will be able to see your work published on gist. The URL is like https://gist.github.com/<your_github_username>
Next time when you use Remix IDE, you can load the content published in gist by clicking on Home`` tab in Remix IDE, scrolling down to the bottom of the page and click on Load from
GIST```. You will need your gist url.