mud verify
This command uploads the source code for the deployed contracts to a public repository, such as a block explorer. The repository then compiles the source code and verifies that the compiled version is identical to what is deployed onchain.
Using the command
-
Before you run
mud verify
you need to create a Foundry profile (opens in a new tab). Change to thepackages/contract
directory and editfoundry.toml
to add a profile with theeth_rpc_url
for your network (if needed). For example, add these lines to add Holesky.[profile.holesky] eth_rpc_url = "https://ethereum-holesky.publicnode.com"
Note that this blockchain has to be supported by the verifier.
-
If using Blockscout, you need to specify the API key:
export ETHERSCAN_API_KEY=<value goes here>
-
Run the command.
pnpm mud verify --worldAddress <address here> --verifier <verifier> --profle <profile>
These are the command line options you can specify on
mud verify
:Option Meaning Type Default value --worldAddress
Verify the contracts of the World at the given address string none, error if unspecified --version
Show version number boolean false
--configPath
Path to the config file string mud.config.ts
--verifier
The verifier to use ( sourcify
, orblockscout
)string --verifierUrl
URL to use to access the verifier's API string depends on the verifier used --profile
The foundry profile to use string local
--srcDir
Source directory string Foundry src
directoryNote that it takes block explorers some time to process new contracts. You should wait 5-10 minutes past deployment before you verify the contract on Etherscan and/or Blockscout.
Examples
-
To verify the world at that address on Holesky (after adding the profile to
foundry.toml
) on sourcify (opens in a new tab):WORLD_ADDRESS=0x816038e244ff78b86a5e7dec9bf281634fb6d2a2 pnpm mud verify --profile holesky --worldAddress $WORLD_ADDRESS --verifier sourcify
-
To verify on Holesky on Blockscout (opens in a new tab):
WORLD_ADDRESS=0x816038e244ff78b86a5e7dec9bf281634fb6d2a2 export ETHERSCAN_API_KEY= ** blockscout API key goes here ** pnpm mud verify --profile holesky --worldAddress $WORLD_ADDRESS --verifier blockscout --verifier-url 'https://eth-holesky.blockscout.com/api?'