Skip to main content

Deploy an ERC-20 Token

OpenZeppelin provides secure, community-vetted smart contract templates that follow best practices.

Step 0: Setup Foundry

If your foundry project isn’t setup yet please go to foundry setup section before proceeding.

Step 1: Create the ERC-20 Contract

Create a contract script in src/MyERC20.sol. Run:
Add the code:
This contract:
  • Inherits from OpenZeppelin’s ERC20 contract
  • Sets the token name to “MyToken” and symbol to “MTK”
  • Mints 1,000,000 tokens to the deployer address upon deployment

Step 2: Compile the Contract

Compile your contract:

Step 3: 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.
Get your wallet address:
Copy the address and head over to the sFUEL Station. Input the address, toggle testnet, and fill up on your SKALE Chain.
Make sure you toggle testnet on first if you’re using a testnet chain!

Step 4: Deploy the Contract

Deploy your ERC-20 token to SKALE:
The --legacy flag is required for SKALE Chains. For more information, see Troubleshooting.
A successful deployment should look something like this:

Step 5: Verify Your Smart Contract

Verify your smart contract on the block explorer:
Replace <DEPLOYED_ADDRESS> with your deployed contract address.