Complete Tutorial: Deploy ERC20 Tokens on Rootstock

Marko BMarko B
9 min read

🎯 What You'll Learn

By following this tutorial, you will:

  • βœ… Deploy your own ERC20 token on Rootstock Mainnet

  • βœ… Configure token parameters (name, symbol, supply, etc.)

  • βœ… Understand how to get rBTC for gas fees

  • βœ… Learn how to verify your contract on block explorers

  • βœ… Set up trading pools for your token (optional)


πŸ› οΈ Prerequisites

Before you start, make sure you have:

Required Software

  • Node.js (version 16 or higher)

  • npm (comes with Node.js)

  • Git (to clone the repository)

  • MetaMask or another Web3 wallet

Required Knowledge

  • Basic understanding of cryptocurrency and tokens

  • Familiarity with command line/terminal

  • Basic knowledge of MetaMask wallet usage

Required Assets

  • rBTC (Rootstock's native token) for gas fees

  • Typically need 0.001-0.01 rBTC for token deployment


πŸ“– What is in the Repository?

Repository provides a ready-to-use solution for deploying ERC20 tokens on Rootstock Mainnet (formerly RSK). Rootstock is a smart contract platform secured by Bitcoin's hashpower, allowing you to create tokens that benefit from Bitcoin's security while having Ethereum-compatible smart contract functionality.

πŸ”— Repository: https://github.com/0xCardiE/rootstock-erc20


πŸš€ Step-by-Step Tutorial

Step 1: Get the Code

Clone the repository from GitHub:
git clone https://github.com/0xCardiE/rootstock-erc20

cd rootstock-erc20

Install dependencies:
npm install

If you encounter dependency conflicts, try:
npm install --legacy-peer-deps

Step 2: Set Up Your Environment

Create your environment file:
cp env.example .env

Edit the .env file with your details:
# Your wallet private key (NEVER share this!)

PRIVATE_KEY=your_private_key_here_without_0x

# Your token configuration

TOKEN_NAME=My Awesome Token

TOKEN_SYMBOL=MAT

TOKEN_DECIMALS=18

TOTAL_SUPPLY=1000000

MINT_PERCENTAGE=100

# Optional: Custom RPC (uses default if not set)

ROOTSTOCK_RPC_URL=https://public-node.rsk.co

How to get your private key:

  • Open MetaMask

  • Click the three dots menu

  • Go to "Account Details"

  • Click "Export Private Key"

  • ⚠️ NEVER share your private key with anyone!

Step 3: Get rBTC for Gas Fees

You need rBTC to pay for transaction fees on Rootstock.

  1. Visit Jumper Exchange: https://jumper.exchange/

  2. Select your source chain (Ethereum, Polygon, etc.)

  3. Select your token (ETH, USDC, etc.)

  4. Select Rootstock as destination

  5. Enter your wallet address

  6. Complete the bridge transaction

Option B: Buy rBTC Directly

  • Use exchanges that support Rootstock

  • Look for rBTC trading pairs

  • Withdraw directly to your Rootstock address

Option C: Bitcoin to rBTC (Advanced)

  • Use Flyover Protocol (official Rootstock bridge)

  • Convert BTC directly to rBTC

  • More technical but fully decentralized

Step 4: Add Rootstock to MetaMask

  1. Open MetaMask

  2. Click network dropdown (usually shows "Ethereum Mainnet")

  3. Click "Add Network"

  4. Enter Rootstock details:

    • Network Name: Rootstock Mainnet

    • RPC URL: https://public-node.rsk.co

    • Chain ID: 30

    • Currency Symbol: rBTC

    • Block Explorer URL: https://explorer.rootstock.io/

Step 5: Configure Your Token

Edit your .env file to customize your token:

# Basic token information

TOKEN_NAME=My Business Token # Full name of your token

TOKEN_SYMBOL=MBT # Short symbol (3-5 characters)

TOKEN_DECIMALS=18 # Usually 18 (like ETH)

TOTAL_SUPPLY=1000000 # Total number of tokens

# Minting configuration

MINT_PERCENTAGE=100 # How much to mint initially (1-100%)

Token Configuration Examples:

Example 1: Community Token

TOKEN_NAME=Community Rewards Token

TOKEN_SYMBOL=CREW

TOTAL_SUPPLY=10000000

MINT_PERCENTAGE=50 # Mint 50% now, 50% later for rewards

Example 2: Business Token

TOKEN_NAME=Business Loyalty Points

TOKEN_SYMBOL=BLP

TOTAL_SUPPLY=5000000

MINT_PERCENTAGE=100 # Mint all tokens immediately

Example 3: Stablecoin-style

TOKEN_NAME=My Stable Coin

TOKEN_SYMBOL=MSC

TOKEN_DECIMALS=6 # Like USDC (6 decimals)

TOTAL_SUPPLY=1000000

MINT_PERCENTAGE=0 # No initial mint, mint as needed

Step 6: Deploy Your Token

Compile the smart contracts:
npm run compile

Deploy to Rootstock Mainnet:
npm run deploy

What happens during deployment:

βœ… Smart contract is deployed to Rootstock

βœ… Initial tokens are minted (based on your percentage)

βœ… Contract ownership is assigned to your address

βœ… Deployment record is saved

βœ… Links to view your token are provided

Step 7: Verify Deployment Success

After deployment, you'll see output like this:

βœ… Token deployed successfully!

πŸ“ Contract Address: 0xabcdef1234567890...

πŸ”— Transaction Hash: 0x1234567890abcdef...

β›½ Gas Used: 1,234,567

πŸ” View on Rootstock Explorer: https://explorer.rootstock.io/address/0xabcdef...

πŸ” View on Blockscout: https://rootstock.blockscout.com/address/0xabcdef...

Important: Save your contract address! You'll need it for:

  • Adding tokens to wallets

  • Creating trading pools

  • Verifying your contract

  • Future interactions

Contract verification makes your code publicly viewable and increases trust.

# Automatic verification (recommended)

npm run verify

# Alternative method

npm run verify:hardhat

Benefits of verification:

  • βœ… Users can see your contract source code

  • βœ… Increases trust and transparency

  • βœ… Better integration with tools and explorers

  • βœ… Easier debugging of transactions

Step 9: Add Your Token to MetaMask

  1. Open MetaMask and ensure you're on Rootstock network

  2. Click "Import tokens"

  3. Enter your contract address (from deployment output)

  4. Token symbol and decimals should auto-fill

  5. Click "Add Custom Token"

  6. Confirm and your tokens will appear in your wallet

Step 10: Create Trading Pools (Optional)

To make your token tradeable, you can create liquidity pools:

  1. Visit Oku Trade: https://docs.oku.trade/home/features/pool/pool-creator

  2. Connect your wallet to Rootstock

  3. Enter your token address

  4. Set initial price and liquidity parameters

  5. Create the Uniswap V3 pool

  6. Add initial liquidity (your tokens + rBTC)


πŸ“‹ Understanding Your Deployment

Files Created

After deployment, you'll find:

  • deployment_history/: Detailed records of your deployments

  • artifacts/: Compiled contract bytecode

  • typechain-types/: TypeScript definitions for your contract

Your Contract Features

Your deployed token includes:

  • βœ… Standard ERC20: transfer, approve, allowance functions

  • βœ… Mintable: Owner can create new tokens

  • βœ… Burnable: Users can destroy their tokens

  • βœ… Ownable: Owner has special privileges

  • βœ… Configurable decimals: Set precision level

Contract Functions You Can Use

For Token Holders:

  • transfer(to, amount) - Send tokens to another address

  • approve(spender, amount) - Allow someone to spend your tokens

  • burn(amount) - Destroy your own tokens

For Contract Owner Only:

  • mint(to, amount) - Create new tokens

  • transferOwnership(newOwner) - Change contract owner


πŸ› οΈ Customization Options

Advanced Configuration

You can customize deployment by modifying these files:

hardhat.config.ts: Network settings, gas prices, RPC URLs deploy/01_deploy_token.ts: Deployment logic, post-deployment actions contracts/RootstockERC20.sol: Token contract code (advanced users)

Using Alternative RPCs

If the default RPC is slow, try alternatives in your .env:

# Alternative RPC endpoints

ROOTSTOCK_RPC_URL=https://mycrypto.rsk.co

# or

ROOTSTOCK_RPC_URL=https://rootstock-mainnet.public.blastapi.io

Testing Before Mainnet

Test your configuration locally:

# Start local blockchain

npm run node

# In another terminal, deploy locally

npm run deploy:local


Rootstock Testnet

Users can safely test smart contracts and dApps without using real assets. Rootstock Testnet mirrors the functionality of the Rootstock mainnet but uses test tokens instead of real RBTC.

  • Network Name: Rootstock Testnet

  • Chain ID: 31

  • Currency Symbol: tRBTC (testnet RBTC)

  • Faucet: faucet.rootstock.io

You can get free testnet tokens (tRBTC) from the faucet to interact with applications and deploy contracts β€” all without spending any real money. It’s a perfect environment for learning, experimenting, or testing before launching on mainnet.

πŸ”§ Troubleshooting

Common Issues and Solutions

❌ "insufficient funds" error

  • Solution: Get more rBTC for gas fees

  • Where to get: Use Jumper Exchange to bridge from other chains

❌ "nonce too high" error

  • Solution: Reset your MetaMask account

  • How: MetaMask Settings β†’ Advanced β†’ Reset Account

❌ "network not found" error

  • Solution: Check your RPC URL in .env file

  • Fix: Try alternative RPC endpoints

❌ Deployment very slow

  • Solution: Try different RPC endpoint

  • Alternative: Increase gas price in hardhat.config.ts

❌ Contract verification fails

  • Solution: Wait a few minutes after deployment

  • Alternative: Try npm run verify:hardhat

Getting Help


πŸ’‘ Use Cases and Examples

Business Loyalty Programs

Deploy tokens to reward customer loyalty:

TOKEN_NAME=Coffee Shop Rewards

TOKEN_SYMBOL=CSR

TOTAL_SUPPLY=1000000

MINT_PERCENTAGE=10 # Start with 10%, mint more as customers earn

Community Governance

Create tokens for community voting:

TOKEN_NAME=Community Governance Token

TOKEN_SYMBOL=CGT

TOTAL_SUPPLY=100000

MINT_PERCENTAGE=100 # All tokens for distribution to members

Project Fundraising

Launch tokens for project funding:

TOKEN_NAME=Project Alpha Token

TOKEN_SYMBOL=PAT

TOTAL_SUPPLY=50000000

MINT_PERCENTAGE=60 # 60% for sale, 40% for team/development

Gaming Tokens

Create in-game currency:

TOKEN_NAME=Game Gold Coins

TOKEN_SYMBOL=GGC

TOTAL_SUPPLY=1000000000

MINT_PERCENTAGE=0 # Mint as players earn them


πŸ”’ Security Best Practices

Protecting Your Private Key

  • βœ… Never share your private key

  • βœ… Never commit .env file to version control

  • βœ… Use hardware wallets for large amounts

  • βœ… Create separate wallets for development vs. production

Smart Contract Security

  • βœ… Test thoroughly before mainnet deployment

  • βœ… Verify contracts on block explorers

  • βœ… Start with small amounts for testing

  • βœ… Consider professional audits for high-value projects

Operational Security

  • βœ… Keep backups of important information

  • βœ… Document your deployments (built-in with this tool)

  • βœ… Monitor your contracts after deployment

  • βœ… Plan for ownership management


πŸ“ˆ Next Steps After Deployment

1. Community Building

  • Share your contract address with your community

  • Explain how to add the token to MetaMask

  • Create documentation for your specific use case

2. Liquidity Management

  • Add initial liquidity to trading pools

  • Consider incentive programs for liquidity providers

  • Monitor trading activity and adjust as needed

3. Marketing and Adoption

  • List on token tracking websites

  • Create social media presence

  • Engage with the Rootstock community

4. Technical Maintenance

  • Monitor contract interactions

  • Plan for future token distribution

  • Keep deployment records safe

  • Consider multi-signature wallets for important operations


πŸ“š Additional Resources

Official Documentation

Tools and Services

Community


🎯 Summary

Congratulations! You now have everything you need to:

  1. βœ… Deploy ERC20 tokens on Rootstock Mainnet

  2. βœ… Configure token parameters for your specific needs

  3. βœ… Verify and secure your smart contracts

  4. βœ… Create trading pools for your tokens

  5. βœ… Troubleshoot common issues

  6. βœ… Follow security best practices

πŸ”— Repository: https://github.com/0xCardiE/rootstock-erc20

Ready to deploy? Run npm run deploy and launch your token on Rootstock! πŸš€


This tutorial covers everything from setup to deployment. For additional questions or support, please refer to the resources listed above or open an issue in the GitHub repository.

0
Subscribe to my newsletter

Read articles from Marko B directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Marko B
Marko B