> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monad.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Verify a smart contract on Monad using Foundry

Once your contract is deployed to a live network, the next step is to verify its source code on the block explorer.

Verifying a contract means uploading its source code, along with the settings used to compile the code, to a
repository (typically maintained by a block explorer). This allows anyone to compile it and compare the generated
bytecode with what is deployed on chain. Doing this is extremely important in an open platform like Monad.

In this guide we'll explain how to do this using [Monad Foundry](/tooling-and-infra/toolkits/monad-foundry).

<Tip>
  This guide assumes you have Monad Foundry installed. See the [installation instructions](/tooling-and-infra/toolkits/monad-foundry#installation) if you haven't set it up yet.
</Tip>

<Tabs>
  <Tab title="Mainnet">
    <Tabs>
      <Tab title="Foundry Monad template (Recommended)">
        <Note>
          The [`foundry-monad`](https://github.com/monad-developers/foundry-monad) template is configured for testnet by default. To use mainnet, update your `foundry.toml` file:

          * Change `eth-rpc-url="https://testnet-rpc.monad.xyz"` to your mainnet RPC URL
          * Change `chain_id = 10143` to `143`
        </Note>

        If you are using [`foundry-monad`](https://github.com/monad-developers/foundry-monad) template, you can use the commands below based on your preferred block explorer:

        <Tabs>
          <Tab title="MonadVision">
            ```sh theme={null}
            forge verify-contract \
                <contract_address> \
                <contract_name> \
                --chain 143 \
                --verifier sourcify \
                --verifier-url https://sourcify-api-monad.blockvision.org/
            ```

            **Example:**

            ```sh theme={null}
            forge verify-contract \
                0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
                Counter \
                --chain 143 \
                --verifier sourcify \
                --verifier-url https://sourcify-api-monad.blockvision.org/
            ```

            On successful verification of smart contract, you should get a similar output in your terminal:

            ```sh theme={null}
            Start verifying contract `0x8fEc29BdEd7A618ab6E3CD945456A79163995769` deployed on monad-mainnet
            Attempting to verify on Sourcify. Pass the --etherscan-api-key <API_KEY> to verify on Etherscan, or use the --verifier flag to verify on another provider.

            Submitting verification for [Counter] "0x8fEc29BdEd7A618ab6E3CD945456A79163995769".
            Contract successfully verified
            ```

            Now check the contract on MonadVision.
          </Tab>

          <Tab title="Monadscan">
            ```sh theme={null}
            forge verify-contract \
                <contract_address> \
                <contract_name> \
                --chain 143 \
                --verifier etherscan \
                --etherscan-api-key YourApiKeyToken \
                --watch
            ```

            **Example:**

            ```sh theme={null}
            forge verify-contract \
                0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
                Counter \
                --chain 143 \
                --verifier etherscan \
                --etherscan-api-key YourApiKeyToken \
                --watch
            ```

            On successful verification of smart contract, you should get a similar output in your terminal:

            ```sh theme={null}
            Start verifying contract `0x8fEc29BdEd7A618ab6E3CD945456A79163995769` deployed on monad-mainnet

            Submitting verification for [src/Counter.sol:Counter] 0x8fEc29BdEd7A618ab6E3CD945456A79163995769.
            Submitted contract for verification:
                    Response: `OK`
                    GUID: `fhxxx4wsub68jce24ejvhe68fqabgtpmpzheqpdqvencgph1za`
                    URL: https://monadscan.com/address/0x8fec29bded7a618ab6e3cd945456a79163995769
            Contract verification status:
            Response: `NOTOK`
            Details: `Pending in queue`
            Warning: Verification is still pending...; waiting 15 seconds before trying again (7 tries remaining)
            Contract verification status:
            Response: `OK`
            Details: `Pass - Verified`
            Contract successfully verified
            ```

            Now check the contract on Monadscan.
          </Tab>

          <Tab title="Socialscan">
            ```sh theme={null}
            forge verify-contract \
                <contract_address> \
                <contract_name> \
                --chain 143 \
                --watch \
                --etherscan-api-key <your_api_key> \
                --verifier-url https://api.socialscan.io/monad-mainnet/v1/explorer/command_api/contract \
                --verifier etherscan
            ```

            **Example:**

            ```sh theme={null}
            forge verify-contract \
                0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
                Counter \
                --chain 143 \
                --watch \
                --etherscan-api-key test \
                --verifier-url https://api.socialscan.io/monad-mainnet/v1/explorer/command_api/contract \
                --verifier etherscan
            ```

            On successful verification of smart contract, you should get a similar output in your terminal:

            ```sh theme={null}
            Start verifying contract `0x8fEc29BdEd7A618ab6E3CD945456A79163995769` deployed on monad-mainnet

            Submitting verification for [src/Counter.sol:Counter] 0x8fEc29BdEd7A618ab6E3CD945456A79163995769.
            Submitted contract for verification:
                    Response: `Contract successfully verified`
                    GUID: `33588004868f0677a3c23734da00fc42895a63542f61b1ed0dbfd2eb6893d7f4`
                    URL: https://monad.socialscan.io/address/0x8fec29bded7a618ab6e3cd945456a79163995769
            Contract verification status:
            Response: `OK`
            Details: `Pass - Verified`
            Contract successfully verified
            ```

            Now check the contract on Socialscan.
          </Tab>
        </Tabs>
      </Tab>

      <Tab title="Default Foundry Project">
        ## 1. Update `foundry.toml` with Monad Configuration

        ```toml lines title="foundry.toml" theme={null}
        [profile.default]
        src = "src"
        out = "out"
        libs = ["lib"]
        metadata = true
        metadata_hash = "none"  # disable ipfs
        use_literal_content = true # use source code

        # Monad Configuration
        eth-rpc-url="https://rpc.monad.xyz"
        chain_id = 143
        ```

        ## 2. Verify the contract using one of the following block explorers:

        <Tabs>
          <Tab title="MonadVision">
            <Note>
              If you are using MonadVision, you can use
              [this guide](https://docs.blockvision.org/reference/verify-smart-contract-on-monad-explorer#/).
              In particular, the [Verify Contract](https://monadvision.com/verify-contract)
              page provides a convenient way to verify your contract.
            </Note>

            ```sh theme={null}
            forge verify-contract \
                <contract_address> \
                <contract_name> \
                --chain 143 \
                --verifier sourcify \
                --verifier-url https://sourcify-api-monad.blockvision.org/
            ```

            **Example:**

            ```sh theme={null}
            forge verify-contract \
                0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
                Counter \
                --chain 143 \
                --verifier sourcify \
                --verifier-url https://sourcify-api-monad.blockvision.org/
            ```

            On successful verification of smart contract, you should get a similar output in your terminal:

            ```sh theme={null}
            Start verifying contract `0x8fEc29BdEd7A618ab6E3CD945456A79163995769` deployed on monad-mainnet
            Attempting to verify on Sourcify. Pass the --etherscan-api-key <API_KEY> to verify on Etherscan, or use the --verifier flag to verify on another provider.

            Submitting verification for [Counter] "0x8fEc29BdEd7A618ab6E3CD945456A79163995769".
            Contract successfully verified
            ```

            Now check the contract on MonadVision.
          </Tab>

          <Tab title="Monadscan">
            ```sh theme={null}
            forge verify-contract \
                <contract_address> \
                <contract_name> \
                --chain 143 \
                --verifier etherscan \
                --etherscan-api-key YourApiKeyToken \
                --watch
            ```

            **Example:**

            ```sh theme={null}
            forge verify-contract \
                0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
                Counter \
                --chain 143 \
                --verifier etherscan \
                --etherscan-api-key YourApiKeyToken \
                --watch
            ```

            On successful verification of smart contract, you should get a similar output in your terminal:

            ```sh theme={null}
            Start verifying contract `0x8fEc29BdEd7A618ab6E3CD945456A79163995769` deployed on monad-mainnet

            Submitting verification for [src/Counter.sol:Counter] 0x8fEc29BdEd7A618ab6E3CD945456A79163995769.
            Submitted contract for verification:
                    Response: `OK`
                    GUID: `fhxxx4wsub68jce24ejvhe68fqabgtpmpzheqpdqvencgph1za`
                    URL: https://monadscan.com/address/0x8fec29bded7a618ab6e3cd945456a79163995769
            Contract verification status:
            Response: `NOTOK`
            Details: `Pending in queue`
            Warning: Verification is still pending...; waiting 15 seconds before trying again (7 tries remaining)
            Contract verification status:
            Response: `OK`
            Details: `Pass - Verified`
            Contract successfully verified
            ```

            Now check the contract on Monadscan.
          </Tab>

          <Tab title="Socialscan">
            ```sh theme={null}
            forge verify-contract \
                <contract_address> \
                <contract_name> \
                --chain 143 \
                --watch \
                --etherscan-api-key <your_api_key> \
                --verifier-url https://api.socialscan.io/monad-mainnet/v1/explorer/command_api/contract \
                --verifier etherscan
            ```

            **Example:**

            ```sh theme={null}
            forge verify-contract \
                0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
                Counter \
                --chain 143 \
                --watch \
                --etherscan-api-key test \
                --verifier-url https://api.socialscan.io/monad-mainnet/v1/explorer/command_api/contract \
                --verifier etherscan
            ```

            On successful verification of smart contract, you should get a similar output in your terminal:

            ```sh theme={null}
            Start verifying contract `0x8fEc29BdEd7A618ab6E3CD945456A79163995769` deployed on monad-mainnet

            Submitting verification for [src/Counter.sol:Counter] 0x8fEc29BdEd7A618ab6E3CD945456A79163995769.
            Submitted contract for verification:
                    Response: `Contract successfully verified`
                    GUID: `33588004868f0677a3c23734da00fc42895a63542f61b1ed0dbfd2eb6893d7f4`
                    URL: https://monad.socialscan.io/address/0x8fec29bded7a618ab6e3cd945456a79163995769
            Contract verification status:
            Response: `OK`
            Details: `Pass - Verified`
            Contract successfully verified
            ```

            Now check the contract on Socialscan.
          </Tab>
        </Tabs>
      </Tab>
    </Tabs>
  </Tab>

  <Tab title="Testnet">
    <Tabs>
      <Tab title="Foundry Monad template (Recommended)">
        If you are using [`foundry-monad`](https://github.com/monad-developers/foundry-monad) template, you can use the commands below based on your preferred block explorer:

        <Tabs>
          <Tab title="MonadVision">
            ```sh theme={null}
            forge verify-contract \
                <contract_address> \
                <contract_name> \
                --chain 10143 \
                --verifier sourcify \
                --verifier-url https://sourcify-api-monad.blockvision.org/
            ```

            **Example:**

            ```sh theme={null}
            forge verify-contract \
                0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
                Counter \
                --chain 10143 \
                --verifier sourcify \
                --verifier-url https://sourcify-api-monad.blockvision.org/
            ```

            On successful verification of smart contract, you should get a similar output in your terminal:

            ```sh theme={null}
            Start verifying contract `0x8fEc29BdEd7A618ab6E3CD945456A79163995769` deployed on monad-testnet
            Attempting to verify on Sourcify. Pass the --etherscan-api-key <API_KEY> to verify on Etherscan, or use the --verifier flag to verify on another provider.

            Submitting verification for [Counter] "0x8fEc29BdEd7A618ab6E3CD945456A79163995769".
            Contract successfully verified
            ```

            Now check the contract on [MonadVision](https://testnet.monadvision.com/).
          </Tab>

          <Tab title="Monadscan">
            ```sh theme={null}
            forge verify-contract \
                <contract_address> \
                <contract_name> \
                --chain 10143 \
                --verifier etherscan \
                --etherscan-api-key YourApiKeyToken \
                --watch
            ```

            **Example:**

            ```sh theme={null}
            forge verify-contract \
                0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
                Counter \
                --chain 10143 \
                --verifier etherscan \
                --etherscan-api-key YourApiKeyToken \
                --watch
            ```

            On successful verification of smart contract, you should get a similar output in your terminal:

            ```sh theme={null}
            Start verifying contract `0x8fEc29BdEd7A618ab6E3CD945456A79163995769` deployed on monad-testnet

            Submitting verification for [src/Counter.sol:Counter] 0x8fEc29BdEd7A618ab6E3CD945456A79163995769.
            Submitted contract for verification:
                    Response: `OK`
                    GUID: `fhxxx4wsub68jce24ejvhe68fqabgtpmpzheqpdqvencgph1za`
                    URL: https://testnet.monadscan.com/address/0x8fec29bded7a618ab6e3cd945456a79163995769
            Contract verification status:
            Response: `NOTOK`
            Details: `Pending in queue`
            Warning: Verification is still pending...; waiting 15 seconds before trying again (7 tries remaining)
            Contract verification status:
            Response: `OK`
            Details: `Pass - Verified`
            Contract successfully verified
            ```

            Now check the contract on [Monadscan](https://testnet.monadscan.com/).
          </Tab>

          <Tab title="Socialscan">
            ```sh theme={null}
            forge verify-contract \
                <contract_address> \
                <contract_name> \
                --chain 10143 \
                --watch \
                --etherscan-api-key <your_api_key> \
                --verifier-url https://api.socialscan.io/monad-testnet/v1/explorer/command_api/contract \
                --verifier etherscan
            ```

            **Example:**

            ```sh theme={null}
            forge verify-contract \
                0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
                Counter \
                --chain 10143 \
                --watch \
                --etherscan-api-key test \
                --verifier-url https://api.socialscan.io/monad-testnet/v1/explorer/command_api/contract \
                --verifier etherscan
            ```

            On successful verification of smart contract, you should get a similar output in your terminal:

            ```sh theme={null}
            Start verifying contract `0x8fEc29BdEd7A618ab6E3CD945456A79163995769` deployed on monad-testnet

            Submitting verification for [src/Counter.sol:Counter] 0x8fEc29BdEd7A618ab6E3CD945456A79163995769.
            Submitted contract for verification:
                    Response: `Contract successfully verified`
                    GUID: `33588004868f0677a3c23734da00fc42895a63542f61b1ed0dbfd2eb6893d7f4`
                    URL: https://api.socialscan.io/monad-testnet/v1/explorer/command_api/address/0x8fec29bded7a618ab6e3cd945456a79163995769
            Contract verification status:
            Response: `OK`
            Details: `Pass - Verified`
            Contract successfully verified
            ```

            Now check the contract on [Socialscan](https://testnet.socialscan.io/).
          </Tab>
        </Tabs>
      </Tab>

      <Tab title="Default Foundry Project">
        <Tip>
          If you use [`foundry-monad`](https://github.com/monad-developers/foundry-monad) you can skip the configuration step
        </Tip>

        ## 1. Update `foundry.toml` with Monad Configuration

        ```toml lines title="foundry.toml" theme={null}
        [profile.default]
        src = "src"
        out = "out"
        libs = ["lib"]  
        metadata = true
        metadata_hash = "none"  # disable ipfs
        use_literal_content = true # use source code

        # Monad Configuration
        eth-rpc-url="https://testnet-rpc.monad.xyz"
        chain_id = 10143
        ```

        ## 2. Verify the contract using one of the following block explorers:

        <Tabs>
          <Tab title="MonadVision">
            ```sh theme={null}
            forge verify-contract \
                <contract_address> \
                <contract_name> \
                --chain 10143 \
                --verifier sourcify \
                --verifier-url https://sourcify-api-monad.blockvision.org/
            ```

            **Example:**

            ```sh theme={null}
            forge verify-contract \
                0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
                Counter \
                --chain 10143 \
                --verifier sourcify \
                --verifier-url https://sourcify-api-monad.blockvision.org/
            ```

            On successful verification of smart contract, you should get a similar output in your terminal:

            ```sh theme={null}
            Start verifying contract `0x8fEc29BdEd7A618ab6E3CD945456A79163995769` deployed on monad-testnet
            Attempting to verify on Sourcify. Pass the --etherscan-api-key <API_KEY> to verify on Etherscan, or use the --verifier flag to verify on another provider.

            Submitting verification for [Counter] "0x8fEc29BdEd7A618ab6E3CD945456A79163995769".
            Contract successfully verified
            ```

            Now check the contract on [MonadVision](https://testnet.monadvision.com/).
          </Tab>

          <Tab title="Monadscan">
            ```sh theme={null}
            forge verify-contract \
                <contract_address> \
                <contract_name> \
                --chain 10143 \
                --verifier etherscan \
                --etherscan-api-key YourApiKeyToken \
                --watch
            ```

            **Example:**

            ```sh theme={null}
            forge verify-contract \
                0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
                Counter \
                --chain 10143 \
                --verifier etherscan \
                --etherscan-api-key YourApiKeyToken \
                --watch
            ```

            On successful verification of smart contract, you should get a similar output in your terminal:

            ```sh theme={null}
            Start verifying contract `0x8fEc29BdEd7A618ab6E3CD945456A79163995769` deployed on monad-testnet

            Submitting verification for [src/Counter.sol:Counter] 0x8fEc29BdEd7A618ab6E3CD945456A79163995769.
            Submitted contract for verification:
                    Response: `OK`
                    GUID: `fhxxx4wsub68jce24ejvhe68fqabgtpmpzheqpdqvencgph1za`
                    URL: https://testnet.monadvision.com/address/0x8fec29bded7a618ab6e3cd945456a79163995769
            Contract verification status:
            Response: `NOTOK`
            Details: `Pending in queue`
            Warning: Verification is still pending...; waiting 15 seconds before trying again (7 tries remaining)
            Contract verification status:
            Response: `OK`
            Details: `Pass - Verified`
            Contract successfully verified
            ```

            Now check the contract on [Monadscan](https://testnet.monadscan.com/).
          </Tab>

          <Tab title="Socialscan">
            ```sh theme={null}
            forge verify-contract \
                <contract_address> \
                <contract_name> \
                --chain 10143 \
                --watch \
                --etherscan-api-key <your_api_key> \
                --verifier-url https://api.socialscan.io/monad-testnet/v1/explorer/command_api/contract \
                --verifier etherscan
            ```

            **Example:**

            ```sh theme={null}
            forge verify-contract \
                0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
                Counter \
                --chain 10143 \
                --watch \
                --etherscan-api-key test \
                --verifier-url https://api.socialscan.io/monad-testnet/v1/explorer/command_api/contract \
                --verifier etherscan
            ```

            On successful verification of smart contract, you should get a similar output in your terminal:

            ```sh theme={null}
            Start verifying contract `0x8fEc29BdEd7A618ab6E3CD945456A79163995769` deployed on monad-testnet

            Submitting verification for [src/Counter.sol:Counter] 0x8fEc29BdEd7A618ab6E3CD945456A79163995769.
            Submitted contract for verification:
                    Response: `Contract successfully verified`
                    GUID: `33588004868f0677a3c23734da00fc42895a63542f61b1ed0dbfd2eb6893d7f4`
                    URL: https://testnet.monadvision.com/address/0x8fec29bded7a618ab6e3cd945456a79163995769
            Contract verification status:
            Response: `OK`
            Details: `Pass - Verified`
            Contract successfully verified
            ```

            Now check the contract on [Socialscan](https://testnet.socialscan.io/).
          </Tab>
        </Tabs>
      </Tab>
    </Tabs>
  </Tab>
</Tabs>
