This tutorial demonstrates how to test and deploy a simple ERC20 token (Cat Token) on the Monad testnet. The token has a fixed supply of 1 billion tokens minted to the deployer's address upon creation.
This repository supplements [insert blog URL, let's add this after we publish the tutorials]. Refer to this blog to follow along and create a GhostGraph to track for onchain events.
This tutorial and the accompanying CatToken implementation are PROVIDED STRICTLY FOR EDUCATIONAL PURPOSES ONLY.
This tutorial:
- Demonstrates the basic ERC20 token deployment process.
- Shows GhostGraph integration for onchain data tracking.
- Illustrates fundamental smart contract testing practices.
- Serves as a learning resource for blockchain developers.
This code is intended for:
- Learning and experimentation.
- Testing and development environments.
- Understanding blockchain concepts.
- Educational workshops and demonstrations.
Warning: Any use of this code in production environments or with real assets could result in significant financial losses. Always engage professional smart contract auditors and security experts before deploying contracts to mainnet.
The ERC20 token implementation includes:
- Fixed supply of 1 billion tokens.
- All tokens minted to the deployer upon creation.
- Standard ERC20 transfer and approval functionality.
- No additional minting capability.
- No special roles or permissions.
Before deploying to the Monad testnet, verify the contract functionality:
forge test -vvThe -vv flag provides verbose output showing test details. The tests verify:
- Initial supply is correctly allocated to the deployer.
- Token transfers work as expected.
- Approval and transferFrom mechanisms function properly.
Copy .env.example and name it .env and fill in your credentials:
cp .env.example .envPRIVATE_KEY=your_private_key_here
MONAD_TESTNET_RPC=https://testnet-rpc.monad.xyz
TOKEN_ADDRESS=fill_this_in_later_after_deploymentsource .envforge build && forge script script/DeployCatToken.s.sol \
--rpc-url $MONAD_TESTNET_RPC \
--broadcastAfter deployment, add the contract address to your .env:
TOKEN_ADDRESS=your_token_address_hereThen execute transfer script:
forge build && forge script script/TransferCatTokens.s.sol \
--rpc-url $MONAD_TESTNET_RPC \
--broadcastYou should see three transactions being submitted onchain with three transfers.
source .envcast call $TOKEN_ADDRESS "balanceOf(address)(uint256)" $YOUR_ADDRESS --rpc-url $MONAD_TESTNET_RPCcast call $TOKEN_ADDRESS "totalSupply()(uint256)" --rpc-url $MONAD_TESTNET_RPCThe contract emits standard ERC20 events:
event Transfer(address indexed from, address indexed to, uint256 value);If deployment fails, verify:
- Your MONAD test token balance is sufficient for gas.
- Private key configuration is correct.
- RPC URL is valid and responsive.
- You're within rate limits.
This project is released under the MIT License.