I am trying to verify a contract with truffle and it does not detect my api key.
truffle run etherscan BEP20Token@0xEC2b1F41E90590cfc44c090DFdeed9DCb55eE000 --network testnet --debug
DEBUG logging is turned ON
Running truffle-plugin-verify v0.5.21
Retrieving network's chain ID
No BscScan API Key provided
It was the first time that my api key gave me problems. I created a new one and it hasn't worked either.
My contract lacks constructor arguments which are often the cause of verification problems. Does not have.
this is my truflle-config-.js:
require('dotenv').config();
const HDWalletProvider = require('truffle-hdwallet-provider-privkey');
const privateKey = [process.env.PRIVATE_KEY];
const apiUrl = process.env.API_URL;
const etherscanAPIBSC = process.env.ETHERSCAN_API_KEY;
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 7545,
network_id: "*" //match any network id
},
// rinkeby: {
// provider: function() {
// return new HDWalletProvider(
// privateKeys.split(','), // array of private keys
// `https://rinkeby.infura.io/v3/${process.env.INFURA_API_KEY}` // Url to an Ethereum node
// )
// },
// gas: 5000000,
// gasPrice: 25000000000,
// network_id: 4
// },
// Useful for deploying to a public network.
// NB: It's important to wrap the provider as a function.
testnet: {
provider: () => new HDWalletProvider(privateKey, `${apiUrl}`),
network_id: 97,
confirmations: 10,
timeoutBlocks: 200,
skipDryRun: true
},
},
contracts_directory: './src/contracts',
contracts_build_directory: './src/abis',
plugins: [
'truffle-plugin-verify'
],
// Configure your compilers
compilers: {
solc: {
optimizer: {
enabled: true,
runs: 200
},
version: "^0.8.0"
}
},
api_keys: {
etherscan: etherscanAPIBSC
}
};
I try to verify on the bsc testnet
Install the library correctly
"devDependencies": {
"@openzeppelin/contracts": "^4.2.0",
"@openzeppelin/test-helpers": "^0.5.12",
"dotenv": "^10.0.0",
"truffle": "^5.3.14",
"truffle-hdwallet-provider-privkey": "^0.3.0",
"truffle-plugin-verify": "^0.5.21",
"webpack": "^4.46.0"
},
I do not know what is the problem. Is there any way to verify that my api works?