Step by Step in-depth tutorial - How to deploy ERC 20 contract on Rootstock Testnet using Remix IDE.

Welcome back smart contract maxis, Today we are starting our new journey as we gonna start a new series of tutorials with a new Blockchain protocol.

You as a smart contract developer might've been writing solidity smart contracts on EVM chains till now. But have you ever imagined you could write Solidity smart contracts on Bitcoin? Yes, you heard right, on Bitcoin. Here comes Rootstock .

What is Rootstock ?

Rootstock is the first and longest-lasting Bitcoin sidechain. It is the only layer 2 solution that combines the security of Bitcoin's proof of work with Ethereum's smart contract capabilities. The platform is open-source, EVM-compatible, and secured by over 60% of Bitcoin’s hashing power, making it the gateway to a vibrant ecosystem of dApps that continues to evolve to become fully trustless.

Hopefully, now you have a basic understanding of Rootstock. Next, Let's dive deep and understand step by step how you can deploy your ERC 20 solidity smart contract on Rootstock testnet just like you do on EVM chains. LETS GO…

Step 1: Set Up Tools

  1. Install MetaMask wallet extension in your browser.
  1. Connect MetaMask to Rootstock Testnet

For more detail follow official docs : https://dev.rootstock.io/dev-tools/wallets/metamask/

Step 2: Write the Contract

Now it's time to write contract. Some of you pretty familiar with Remix IDE a phenomenal tool for writing, testing and deploying smart contract. follow along.

  1. Open Remix IDE at https://remix.ethereum.org/
  1. Create a new file named MyToken.sol

  1. Paste the following simple ERC20 contract code

     // SPDX-License-Identifier: MIT
     pragma solidity ^0.8.0;
    
     contract MyToken {
         string public name = "MyToken";
         string public symbol = "MTK";
         uint256 public totalSupply = 1000000 * 10 ** 18;
    
         mapping(address => uint256) balances;
    
         constructor() {
             balances[msg.sender] = totalSupply;
         }
    
         function balanceOf(address _owner) public view returns (uint256) {
             return balances[_owner];
         }
     }
    

Step 3: Compile the Contract

  1. Click on the "Solidity Compiler" icon in Remix sidebar.
  1. Select compiler version 0.8.0.
  1. Click "Compile MyToken.sol" (you can check Auto Compile ✅)

    Step 4: Deploy the Contract

    1. Click on the "Deploy & Run Transactions" icon.
  1. Under "Environment", select "Injected Provider - MetaMask".
  1. Choose your account in MetaMask.
  1. Select "MyToken" under "Contract".
  1. Click the "Deploy" button.

  1. Confirm the transaction in MetaMask.

    Now open up your terminal and see the transactions details.

    Huge congratulations 🎊 you successfully deployed your ERC 20 solidity smart contract on Rootstock Testnet. Let's go further and interact with that contract.

Step 5: Interact with the Contract

  1. Expand the deployed contract in Remix.
  1. Try calling functions like name(), symbol(), balanceOf() etc.
  1. Experiment with transferring tokens using the transfer() function (which you'll need to add to the contract).

    You can customize your contract and play around it.

I hope you enjoyed this tutorial and learned how to deploy solidity smart contract on Rootstock test Network. we will continue this series and in next tutorial we will learn How to deploy solidity smart contract on Rootstock testnet using more professional way using industry tools like Hardhat and Foundry.

Till Explore the docs and understand Rootstock - https://dev.rootstock.io/