A simple smart contract built with Foundry for learning and testing purposes.
- Basic counter functionality with increment and set operations
- Deployed using Foundry scripts
- Foundry installed
- Clone and navigate to the project:
cd simple-contract-test- Install dependencies:
forge install- Create environment file:
cp .env.example .env- Edit
.envfile and add your private key:
PRIVATE_KEY=your_private_key_here./deploy.sh monad_testnet# Dry run (simulation)
forge script script/Counter.s.sol --rpc-url monad_testnet
# Deploy to Monad Testnet (verification done separately with Sourcify)
forge script script/Counter.s.sol \
--rpc-url monad_testnet \
--private-key $PRIVATE_KEY \
--broadcast
# Deploy to other networks with auto-verification
forge script script/Counter.s.sol \
--rpc-url sepolia \
--private-key $PRIVATE_KEY \
--broadcast \
--verifyFor Monad Testnet, use Sourcify for contract verification:
./verify-sourcify.sh [contract_address] monad_testnetExample:
./verify-sourcify.sh 0x123...abc monad_testnetFor other networks with automatic verification:
./verify.sh [contract_address] [network]Example:
./verify.sh 0x123...abc sepoliaRun the test suite:
forge testRun tests with gas reporting:
forge test --gas-report- Monad Testnet (Chain ID: 10143) - Primary testnet
Get test tokens from these faucets:
- Monad Testnet: Visit Monad Discord for faucet access
- Sourcify: https://sourcify-api-monad.blockvision.org (for Monad Testnet)
├── src/
│ └── Counter.sol # Main contract
├── script/
│ └── Counter.s.sol # Deployment script
├── test/
│ └── Counter.t.sol # Test file
├── deploy.sh # Deployment helper script
├── verify.sh # Verification helper script
└── foundry.toml # Foundry configuration
For more information about Foundry: https://book.getfoundry.sh/