我在polygon mumbai testnet上部署了一个简单的NFT智能合约,但当我试图验证它时,它显示了一个错误。请指导我如何验证…
这是我得到的错误
PS C:UsersSumitsDesktoptruffle> truffle run verify MyNFT --network matic --debug
DEBUG logging is turned ON
Running truffle-plugin-verify v0.5.20
Retrieving network's chain ID
Verifying MyNFT
Reading artifact file at C:UsersSumitsDesktoptrufflebuildcontractsMyNFT.json
Failed to verify 1 contract(s): MyNFT
PS C:UsersSumitsDesktoptruffle>
这是我的松露配置js
const HDWalletProvider = require('@truffle/hdwallet-provider');
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();
module.exports = {
networks: {
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 8545, // Standard Ethereum port (default: none)
network_id: "*", // Any network (default: none)
},
matic: {
provider: () => new HDWalletProvider(mnemonic, `https://rpc-mumbai.maticvigil.com`),
network_id: 80001,
confirmations: 2,
timeoutBlocks: 200,
skipDryRun: true
},
},
// Set default mocha options here, use special reporters etc.
mocha: {
// timeout: 100000
},
// Configure your compilers
compilers: {
solc: {
version: "^0.8.0",
}
},
plugins: ['truffle-plugin-verify'],
api_keys: {
polygonscan: 'BTWY55K812M*******WM9NAAQP1H3'
}
}
首先部署合约:
truffle migrate --network matic --reset
我不确定你是否成功地将其部署到matic网络,因为你的配置似乎不正确:
matic: {
// make sure you set up provider correct
provider: () => new HDWalletProvider(mnemonic, `https://rpc-mumbai.maticvigil.com/v1/YOURPROJECTID`),
network_id: 80001,
confirmations: 2,
timeoutBlocks: 200,
skipDryRun: true
},
然后验证。
truffle run verify ContractName --network matic
ContractName
应该是合同的名称,而不是文件的名称
请确保您将polygonscan-api密钥放在小写中