Note
In this Foundry template, the default chain is monadTestnet
. If you wish to change it, change the network in foundry.toml
Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
Foundry consists of:
- Forge: Ethereum testing framework (like Truffle, Hardhat, and DappTools).
- Cast: Swiss army knife for interacting with EVM smart contracts, sending transactions, and getting chain data.
- Anvil: Local Ethereum node, akin to Ganache, Hardhat Network.
- Chisel: Fast, utilitarian, and verbose Solidity REPL.
forge build
forge test
forge fmt
forge snapshot
anvil
First, you need to create a keystore file. Do not forget to remember the password! You will need it to deploy your contract.
cast wallet import monad-deployer --private-key $(cast wallet new | grep 'Private key:' | awk '{print $3}')
After creating the keystore, you can read its address using:
cast wallet address --account monad-deployer
The command above will create a keystore file named monad-deployer
in the ~/.foundry/keystores
directory.
Then, you can deploy your contract to the Monad Testnet using the keystore file you created.
forge create src/Counter.sol:Counter --account monad-deployer --broadcast
forge verify-contract \
<contract_address> \
src/Counter.sol:Counter \
--chain 10143 \
--verifier sourcify \
--verifier-url https://sourcify-api-monad.blockvision.org
cast <subcommand>
forge --help
anvil --help
cast --help
This error happens when you don't have enough balance to deploy your contract. You can check your balance with the following command:
cast wallet address --account monad-deployer
forge create \
src/Counter.sol:Counter \
--account monad-deployer \
--broadcast \
--constructor-args <constructor_arguments>
forge verify-contract \
<contract_address> \
src/Counter.sol:Counter \
--chain 10143 \
--verifier sourcify \
--verifier-url https://sourcify-api-monad.blockvision.org \
--constructor-args <abi_encoded_constructor_arguments>
Please refer to the Foundry Book for more information.