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
- Install MetaMask wallet extension in your browser.
Connect MetaMask to Rootstock Testnet
Go to MetaMask settings
Add Network
Enter these details
Network Name: Rootstock Testnet
RPC URL: https://public-node.rsk.co/
Chain ID: 31
Currency Symbol: tRBTC
Block explorer URL: https://explorer.testnet.rootstock.io/
Get some test RBTC from the Rootstock faucet : Here is the link.
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.
- Open Remix IDE at https://remix.ethereum.org/
Create a new file named
MyToken.sol
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
- Click on the "Solidity Compiler" icon in Remix sidebar.
- Select compiler version 0.8.0.
Click "Compile MyToken.sol" (you can check Auto Compile ✅)
Step 4: Deploy the Contract
- Click on the "Deploy & Run Transactions" icon.
- Under "Environment", select "Injected Provider - MetaMask".
- Choose your account in MetaMask.
- Select "MyToken" under "Contract".
Click the "Deploy" button.
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
- Expand the deployed contract in Remix.
- Try calling functions like
name()
,symbol()
,balanceOf()
etc.
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/