Solidity smart contract deployment using REMIX IDE
Last updated
Last updated
Open Remix IDE using the below link, https://remix.ethereum.org/#lang=en&optimize=false&runs=200&evmVersion=null&version=soljson-v0.8.18+commit.87f61d96.js. The default workspace looks similar like below,
A) Next step is to create a workspace, click on the Workspace option and select create -> create workspace. This will open a new tab to choose the type of workspace as required.
B) The new tab has various Template options to choose for the new workspace. The option selected here is Open Zeppelin ->ERC20. Open Zeppelin is the open source library/framework mainly used in the smart contract deployment for ethereum. It provides a set of audited and reusable contracts for the developers.
C) Click on OK, the next page has some customizable template options for the new workspace. Choose the required options and click OK to create the workspace.
The template settings can be modified anytime after the workspace creation too.
Now, the Workspace is created successfully.
D) The new workspace created will be similar to the below page and it has its own files and folders.
There is one more application called MetaMask, which is required to begin the smart contract deployment. If the user has an existing MetaMask wallet then it can be used or else the new account has to be created. The steps to deploy MetaMask is explained in the below section.
Once the MetaMask configuration is completed, switch back to the REMIX IDE workspace to resume the steps.
Choose Deploy & Run Transactions tab from the left pane of the workspace. To select the Environment option, click on the drop-down menu to choose Injected provider - MetaMask.
A) Next, a new tab will prompt to connect with Metamask wallet. Choose the desired MetaMask account that has to be connected with the Remix IDE workspace.
B) Click on Next to see the below screen and provide permission for the REMIX IDE to view the wallet details. Finally, click on Connect to complete the environment setup.
C) Now, the MetaMask wallet is connected with the REMIX IDE. After successful connection, the Metamask wallet address will be populated in the setup details. Also, the wallet and its balance will be visible from the IDE.
Switch to OpenZeppelin workspace to begin with the smart contract deployment. From the list of folders, select contracts and click on MyToken.sol which has the default configuration.
The contract should be modified based on the requirements. The boiler plate for MyToken.sol is given below:
The given example is used to mint 1000 token and based on user option the value can be modified.
The token value must be followed by 18 Zero's. Because, the default setting for Ethereum minting is the values must be followed by "0" up to 18 decimal counts.
The contract is modified and it is ready to be deployed. Click on CTRL+S to complete the compilation, only then the updates will be reflected.
One more option to compile is, choose Solidity Compiler option and select compile MyToken.sol button to finish compilation.
Next, add the contract script in the Environment value and contract deployment is one step away!
A) Switch to Deploy & Run Environment option, choose MyToken - contract/MyToken.sol option from the drop down list.
B) Click on Deploy, the MetaMask window will be prompted to complete the transaction. Click on confirm to finish the contract deployment.
After confirmation, the deployment process begins and finally the contract deployment will be completed. The contract address is generated and click on copy icon to have a copy of address for verification.
The contract address will be similar to the below format:
Solidity smart contract deployment using REMIX IDE is successful! ✅