question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong message: Invalid API Key

See original GitHub issue

Describe the bug

I am working with Avalanche testnet and trying to verify smart contracts however the answer that I am getting is: “Invalid API Key”. I run the verification once again using --debug. Snowtrace is responding with the provided apikey to the HTTP requests so I guess the apikey is not the problem.

Steps To Reproduce

My last attempt was using metacoin example from truffle, same steps described by Avalanche documentation:

https://docs.avax.network/dapps/smart-contracts/verify-smart-contracts-with-truffle-verify/

Environment information

  • Operating System: Ubuntu 21.04
  • Node version: 16.13.2
  • Truffle version: 5.5.13
  • truffle-plugin-verify version: 0.5.25

truffle-config.js content:

const HDWalletProvider = require(“@truffle/hdwallet-provider”); const { apikey, mnemonic } = require(“./.env.json”);

module.exports = { plugins: [ ‘truffle-plugin-verify’ ], api_keys: { snowtrace: apikey }, networks: { fuji: { provider: () => new HDWalletProvider(mnemonic, https://api.avax-test.network/ext/bc/C/rpc), network_id: 43113, timeoutBlocks: 200, confirmations: 5 } } };

Debug output

npx truffle run verify ConvertLib MetaCoin --network fuji --debugDEBUG logging is turned ON Running truffle-plugin-verify v0.5.25 Retrieving network’s network ID & chain ID Verifying ConvertLib Reading artifact file at /home/gsierro/Data/workspace/Avalanche/MetaCoin/build/contracts/ConvertLib.json Retrieving constructor parameters from https://api-testnet.snowtrace.io/api?apiKey=[XXXXX]&module=account&action=txlist&address=0x2b1330Be824d7d4018ef9b909f679Fba3Dc1Dff0&page=1&sort=asc&offset=1 Constructor parameters retrieved: 0x Sending verify request with POST arguments: { “apikey”: “[XXXXX]”, “module”: “contract”, “action”: “verifysourcecode”, “contractaddress”: “0x2b1330Be824d7d4018ef9b909f679Fba3Dc1Dff0”, “sourceCode”: “{"language":"Solidity","sources":{"/contracts/ConvertLib.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity >=0.4.25 <0.7.0;\n\nlibrary ConvertLib{\n\tfunction convert(uint amount,uint conversionRate) public pure returns (uint convertedAmount)\n\t{\n\t\treturn amount * conversionRate;\n\t}\n}\n"}},"settings":{"remappings":[],"optimizer":{"enabled":false,"runs":200},"evmVersion":"istanbul","libraries":{}}}”, “codeformat”: “solidity-standard-json-input”, “contractname”: “/contracts/ConvertLib.sol:ConvertLib”, “compilerversion”: “v0.5.16+commit.9c3226ce”, “constructorArguements”: “” } Invalid API Key Verifying MetaCoin Reading artifact file at /home/gsierro/Data/workspace/Avalanche/MetaCoin/build/contracts/MetaCoin.json Retrieving constructor parameters from https://api-testnet.snowtrace.io/api?apiKey=[XXXXX]&module=account&action=txlist&address=0xAD6380E56FE1D6d4Cd8010459958fD8f8682Bd0e&page=1&sort=asc&offset=1 Constructor parameters retrieved: 0x Reading artifact file at /home/gsierro/Data/workspace/Avalanche/MetaCoin/build/contracts/ConvertLib.json Sending verify request with POST arguments: { “apikey”: “[XXXXX]”, “module”: “contract”, “action”: “verifysourcecode”, “contractaddress”: “0xAD6380E56FE1D6d4Cd8010459958fD8f8682Bd0e”, “sourceCode”: “{"language":"Solidity","sources":{"/contracts/MetaCoin.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity >=0.4.25 <0.7.0;\n\nimport \"./ConvertLib.sol\";\n\n// This is just a simple example of a coin-like contract.\n// It is not standards compatible and cannot be expected to talk to other\n// coin/token contracts. If you want to create a standards-compliant\n// token, see: https://github.com/ConsenSys/Tokens. Cheers!\n\ncontract MetaCoin {\n\tmapping (address => uint) balances;\n\n\tevent Transfer(address indexed _from, address indexed _to, uint256 _value);\n\n\tconstructor() public {\n\t\tbalances[tx.origin] = 10000;\n\t}\n\n\tfunction sendCoin(address receiver, uint amount) public returns(bool sufficient) {\n\t\tif (balances[msg.sender] < amount) return false;\n\t\tbalances[msg.sender] -= amount;\n\t\tbalances[receiver] += amount;\n\t\temit Transfer(msg.sender, receiver, amount);\n\t\treturn true;\n\t}\n\n\tfunction getBalanceInEth(address addr) public view returns(uint){\n\t\treturn ConvertLib.convert(getBalance(addr),2);\n\t}\n\n\tfunction getBalance(address addr) public view returns(uint) {\n\t\treturn balances[addr];\n\t}\n}\n"},"/contracts/ConvertLib.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity >=0.4.25 <0.7.0;\n\nlibrary ConvertLib{\n\tfunction convert(uint amount,uint conversionRate) public pure returns (uint convertedAmount)\n\t{\n\t\treturn amount * conversionRate;\n\t}\n}\n"}},"settings":{"remappings":[],"optimizer":{"enabled":false,"runs":200},"evmVersion":"istanbul","libraries":{"/contracts/ConvertLib.sol":{"ConvertLib":"0x2b1330Be824d7d4018ef9b909f679Fba3Dc1Dff0"}}}}”, “codeformat”: “solidity-standard-json-input”, “contractname”: “/contracts/MetaCoin.sol:MetaCoin”, “compilerversion”: “v0.5.16+commit.9c3226ce”, “constructorArguements”: “” } Invalid API Key

Thanks for your help!

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
minimozcommented, Jun 9, 2022

Problem was solved for me too, didn’t change anything in my config.

I use "truffle-plugin-verify": "^0.5.25".

Thank you 🙏

1reaction
0xV4L3NT1N3commented, Jun 4, 2022

gm all, just dropping in here to mention I gave it a try with truffle verify 0.5.25 which didn’t output any errors or invalid keys for me.

@gsierroqx can your API Key be used to call any other endpoints from SnowTrace’s docs ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why am I getting The API key is invalid error? - Zoho Cares
You will get invalid API key error in any of the following cases: Incorrect API key. Please ensure that you have provided the...
Read more >
“Invalid API Key. Please verify your API key is valid” Error
I go across to Google Search Console to get my key and I get it. Now I have had a few issues with...
Read more >
Why am I getting an invalid API key error in my shopping cart?
Go to Wordpress > Printful > Settings; Delete the Printful Store API Key and click Save changes; Go to your Dashboard and click...
Read more >
Invalid Api Key Error - Wowza Community
Invalid Api Key Error ... This error triggers when the proper keys and headers were not configured properly as shown below. ... Lastly,...
Read more >
Invalid API Key - SMS-Magic
Possible Causes · You are trying to register the application on a refreshed sandbox while the username is still registered on the portal...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found