Deploy an ERC-20 Token
This tutorial will walk you through deploying an ERC-20 token on SKALE using Foundry and OpenZeppelin Contracts. OpenZeppelin provides secure, community-vetted smart contract templates that follow best practices.Prerequisites
- Rust installed on your machine
- Foundry installed
- A wallet with sFUEL
- Basic knowledge of Solidity
- A SKALE Chain endpoint
If you are on a Windows machine, you will need to use Windows Subsystem for Linux (WSL), since Foundry doesn’t work natively on Windows.
Step 1: Install Foundry
If you haven’t already installed Foundry, run:Step 2: Create a New Foundry Project
Run the following in your terminal:Step 3: Install OpenZeppelin Contracts
Install OpenZeppelin Contracts using Foundry:lib directory.
Step 4: Configure Remappings
Update yourremappings.txt file (or create it if it doesn’t exist) to include:
Step 5: Update Foundry Configuration
Update thefoundry.toml file to add your SKALE Chain endpoint:
Step 6: Create the ERC-20 Contract
Create a new filesrc/MyERC20.sol:
- Inherits from OpenZeppelin’s
ERC20contract - Sets the token name to “MyToken” and symbol to “MTK”
- Mints 1,000,000 tokens to the deployer address upon deployment
Step 7: Compile the Contract
Compile your contract:Step 8: Prepare Signer for Deployment
This tutorial uses the Foundry Keystore for increased security. Create a new keystore:Provide a password to encrypt the keystore file when running the above command. If you forget this password, you will not be able to recover it.
Step 9: Deploy the Contract
Deploy your ERC-20 token to SKALE:The
--legacy flag is required for SKALE Chains. For more information, see Troubleshooting.Step 10: Verify Your Smart Contract
Verify your smart contract on the block explorer:<DEPLOYED_ADDRESS> with your deployed contract address.
Next Steps
Congratulations! You’ve successfully deployed an ERC-20 token on SKALE. You can now:- Transfer tokens to other addresses
- Approve spending allowances
- Integrate the token into your dApp
