DemoToken, a fixed-supply ERC-20 token built on OpenZeppelin Contracts. Standard ERC-20 contracts work on Sei without changes.
Before you start
- A Sei Testnet account that holds some SEI for gas. Get testnet SEI from the faucet. Use a throwaway account that holds only testnet funds.
- For Foundry, the account’s private key in the
PRIVATE_KEYenvironment variable. - For Hardhat, the private key in the Hardhat keystore, as the Hardhat guide shows.
- For Remix, a browser wallet such as MetaMask.
The contract
DemoToken.sol
decimals() returns 18, so the contract stores the supply as 1,000,000 × 1018 base units.
Deploy the contract
- Foundry
- Hardhat
- Remix
Run these commands to create a project, install OpenZeppelin Contracts, and write the import remappings to Foundry prints the token address after For project settings, tests, and deploy scripts, see the Foundry guide.
remappings.txt:remappings.txt maps @openzeppelin/contracts/ to the installed library. Foundry finds that mapping on its own, but editors and other Solidity tools read it from this file.Save the contract as src/DemoToken.sol. Then deploy it:Deployed to:.Without
--broadcast, forge create only simulates the deployment. It prints the transaction, but it does not send it.Verify the source
Verification publishes your source code on Seiscan, so that anyone can read the contract. Sourcify verification does not need an API key. Replace0xYourTokenAddress with the deployed address:
Read the token back
To confirm the deployment, read the token’s metadata and your balance. First, install a client library:await. Save each one as a .mts file, such as script.mts. Run it with npx tsx script.mts on Node.js 18 or later. In a new npm project, tsx compiles a plain .ts file as CommonJS, where top-level await does not work.
Replace 0xYourTokenAddress with the token address and 0xYourAddress with the deployer address:
1000000.0, because formatUnits in ethers always includes a decimal place.
Related recipes
- ERC-20 interaction: transfers, approvals, and allowances
- Listen to events: stream the token’s
Transferevents - Deploy and verify: deploy any contract with viem, ethers, Foundry, or Hardhat