Solidity smart contract deployment using REMIX IDE

Deployment using REMIX IDE

  1. 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,

  1. 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.

  1. 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.

pageMetamask Deployment
  1. Once the MetaMask configuration is completed, switch back to the REMIX IDE workspace to resume the steps.

  2. 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.

  1. 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.

  1. 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.

  1. The contract should be modified based on the requirements. The boiler plate for MyToken.sol is given below:

```remix-solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
    constructor() ERC20("TEST_PPY_2.0", "TEST") 
    {
    _mint(msg.sender, 1000000000000000000000);
    }
}
```

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.

  1. 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.

  1. 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:

// contract address example
```remix-solidity
0xde1aF1323bD6d092a9199d8f050A9806bcb57530
```

Solidity smart contract deployment using REMIX IDE is successful! ✅

Last updated