CLI
mud verify

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

  1. Before you run mud verify you need to create a Foundry profile (opens in a new tab). Change to the packages/contract directory and edit foundry.toml to add a profile with the eth_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.

  2. If using Blockscout, you need to specify the API key:

    export ETHERSCAN_API_KEY=<value goes here>
  3. 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:

    OptionMeaningTypeDefault value
    --worldAddressVerify the contracts of the World at the given addressstringnone, error if unspecified
    --versionShow version numberbooleanfalse
    --configPathPath to the config filestringmud.config.ts
    --verifierThe verifier to use (sourcify, or blockscout)string
    --verifierUrlURL to use to access the verifier's APIstringdepends on the verifier used
    --profileThe foundry profile to usestringlocal
    --srcDirSource directorystringFoundry src directory

    Note 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?'