本指南假设您已安装 Foundry v1.8.0 或更高版本,并在
foundry.toml 中配置了 network = "monad"。如果尚未设置,请参见安装与配置说明。- 主网
- 测试网
- Foundry Monad 模板(推荐)
- 默认 Foundry 项目
foundry-monad 模板默认为测试网配置。要使用主网,请更新您的 foundry.toml 文件:- 将
eth-rpc-url="https://testnet-rpc.monad.xyz"改为您的主网 RPC URL - 将
chain_id = 10143改为143
foundry-monad 模板,可以根据您首选的区块浏览器使用以下命令:- MonadVision
- Monadscan
forge verify-contract \
<contract_address> \
<contract_name> \
--chain 143 \
--verifier sourcify \
--verifier-url https://sourcify-api-monad.blockvision.org/
forge verify-contract \
0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
Counter \
--chain 143 \
--verifier sourcify \
--verifier-url https://sourcify-api-monad.blockvision.org/
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
forge verify-contract \
<contract_address> \
<contract_name> \
--chain 143 \
--verifier etherscan \
--etherscan-api-key YourApiKeyToken \
--watch
forge verify-contract \
0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
Counter \
--chain 143 \
--verifier etherscan \
--etherscan-api-key YourApiKeyToken \
--watch
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
1. 使用 Monad 配置更新 foundry.toml
foundry.toml
[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. 使用以下区块浏览器之一验证合约:
- MonadVision
- Monadscan
如果您使用 MonadVision,可以使用
本指南。
特别是,Verify Contract
页面提供了一种便捷的合约验证方式。
forge verify-contract \
<contract_address> \
<contract_name> \
--chain 143 \
--verifier sourcify \
--verifier-url https://sourcify-api-monad.blockvision.org/
forge verify-contract \
0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
Counter \
--chain 143 \
--verifier sourcify \
--verifier-url https://sourcify-api-monad.blockvision.org/
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
forge verify-contract \
<contract_address> \
<contract_name> \
--chain 143 \
--verifier etherscan \
--etherscan-api-key YourApiKeyToken \
--watch
forge verify-contract \
0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
Counter \
--chain 143 \
--verifier etherscan \
--etherscan-api-key YourApiKeyToken \
--watch
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
- Foundry Monad 模板(推荐)
- 默认 Foundry 项目
如果您使用 示例:智能合约验证成功后,您应该在终端中看到类似如下的输出:现在到 MonadVision 上查看合约。示例:智能合约验证成功后,您应该在终端中看到类似如下的输出:现在到 Monadscan 上查看合约。
foundry-monad 模板,可以根据您首选的区块浏览器使用以下命令:- MonadVision
- Monadscan
forge verify-contract \
<contract_address> \
<contract_name> \
--chain 10143 \
--verifier sourcify \
--verifier-url https://sourcify-api-monad.blockvision.org/
forge verify-contract \
0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
Counter \
--chain 10143 \
--verifier sourcify \
--verifier-url https://sourcify-api-monad.blockvision.org/
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
forge verify-contract \
<contract_address> \
<contract_name> \
--chain 10143 \
--verifier etherscan \
--etherscan-api-key YourApiKeyToken \
--watch
forge verify-contract \
0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
Counter \
--chain 10143 \
--verifier etherscan \
--etherscan-api-key YourApiKeyToken \
--watch
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
如果您使用
foundry-monad,可以跳过配置步骤1. 使用 Monad 配置更新 foundry.toml
foundry.toml
[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. 使用以下区块浏览器之一验证合约:
- MonadVision
- Monadscan
forge verify-contract \
<contract_address> \
<contract_name> \
--chain 10143 \
--verifier sourcify \
--verifier-url https://sourcify-api-monad.blockvision.org/
forge verify-contract \
0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
Counter \
--chain 10143 \
--verifier sourcify \
--verifier-url https://sourcify-api-monad.blockvision.org/
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
forge verify-contract \
<contract_address> \
<contract_name> \
--chain 10143 \
--verifier etherscan \
--etherscan-api-key YourApiKeyToken \
--watch
forge verify-contract \
0x8fEc29BdEd7A618ab6E3CD945456A79163995769 \
Counter \
--chain 10143 \
--verifier etherscan \
--etherscan-api-key YourApiKeyToken \
--watch
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

