Skip to main content

Using Foundry

Foundry is a smart contract development toolchain.

Follow the Foundry documentation for general installation and overview.

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.

Compile your Gnosis Contract

Compile your contract with this command:

forge build

Additional compilation options can be found here.

Deploy your Contract

Forge can only deploy one contract at a time.

Because Solidity files may contain multiple contracts, :<YourContract> (Seen below) specifies which contract to deploy.

Deploy your contract on Gnosis with the following Forge command:

forge create --rpc-url --private-key <your_private_key> src/<YourContract>.sol:<YourContract>

Deploy with constructor arguments:

Use the --constructor-args flag to pass arguments to the constructor:

forge create --rpc-url \
--constructor-args <argument-1> <argument-2...>\
--private-key <your_private_key> src/<YourToken>.sol:<YourToken> \

Verify your Contract

Verify your Gnosis contract on deployment using Etherscan:

Use the --verify flag as shown below:

forge create --rpc-url \
--private-key <your_private_key> src/<YourToken>.sol:<YourToken> \
--etherscan-api-key <your_etherscan_api_key> \

For information regarding pre-existing contract verification, visit the official Forge documentation.

For further Contract Verification information, visit our official page