Skip to content

monad-developers/foundry-monad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monad-flavored Foundry

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.

Documentation

https://book.getfoundry.sh/

Usage

Build

forge build

Test

forge test

Format

forge fmt

Gas Snapshots

forge snapshot

Anvil

anvil

Deploy to Monad Testnet

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

Verify Contract

forge verify-contract \
  <contract_address> \
  src/Counter.sol:Counter \
  --chain 10143 \
  --verifier sourcify \
  --verifier-url https://sourcify-api-monad.blockvision.org

Cast

Cast reference

cast <subcommand>

Help

forge --help
anvil --help
cast --help

FAQ

Error: Error: server returned an error response: error code -32603: Signer had insufficient balance

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

I have constructor arguments, how do I deploy my contract?

forge create \
  src/Counter.sol:Counter \
  --account monad-deployer \
  --broadcast \
  --constructor-args <constructor_arguments>

I have constructor arguments, how do I verify my contract?

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.

About

Monad Configured Foundry template

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5