A Guide to Easily Verify Your Smart Contract Programmatically Using Routescan's API

This article provides instructions on utilizing Routescan’s API to verify your smart contract. This process is particularly advantageous for those who have deployed their contract using Remix and are seeking a straightforward verification method.

📘 Instructions Prerequisites involve having a deployed smart contract, preferably using Remix. Additionally, ensure you have Postman or any other API platform installed on your computer (or accessible through online services), along with your contract's source code and the parameters utilized during deployment (detailed further in the subsequent steps).

👉 If you wish to learn how to deploy a smart contract using Remix, consult this guide:Creating and Deploying a Contract — Remix - Ethereum IDE 1 documentation

🔹 After compiling and deploying your smart contract with Remix IDE, make sure to take note of the following:

  • The compiler version used (1),

  • The EVM version used (2),

  • The optimization used (3)

  • The contract name used (4).

  • The contract address deployed on-chain (you can find that in the contract creation transaction)

https://ibb.co/VBL7jyV
https://ibb.co/VBL7jyV

🔹 Additionally, generate a flattened version of your contract since the API call currently only supports a solidity-single-file format. To create a flattened version, right-click on the file and select "flatten." This action will produce another version of your code in a flattened format.

https://ibb.co/jL6S6Lc
https://ibb.co/jL6S6Lc

🔹 For the upcoming step, you must have an API platform installed on your computer (or available online). In this tutorial, we will be using Postman. You can obtain the software for free by downloading it and creating an account at the following link: Postman API Platform | Sign Up for Free

🔹 Upon installing Postman, please choose the "import" option and utilize the provided file here. This action will generate the necessary API calls for verifying your contract and checking the verification status. Routescan.postman_collection2.json -→

https://ibb.co/3zmGJ0S
https://ibb.co/3zmGJ0S

🔹 After importing the Postman JSON, you should observe two pre-compiled API calls, as illustrated in the image.

https://ibb.co/72xX6J6
https://ibb.co/72xX6J6

🔹 Begin by inspecting the URL; the imported one is tailored for verification on the Avalanche Fuji testnet. Adjust the URL to match the desired chain. For instance, if verification on the Avalanche mainnet is sought, replace "/testnet" with "/mainnet" and ensure the chain ID aligns with that of the Avalanche mainnet, which is typically 43114.

https://ibb.co/6nyc18G
https://ibb.co/6nyc18G

🔹 Now, proceed with the initiation of the POST API call to verify your smart contract. Start by entering the necessary values with the correct information:

  1. Contract address deployed on-chain (retrieve from the contract creation transaction)

  2. Source code(use the flattened version) - Please exercise patience, especially with substantial code, as Postman may exhibit slowness during the copy-pasting process.

  3. Code format: Keep it as solidity single file, as the API call currently supports only this format.

  4. Contract name used - Refer to step 1.

  5. Compiler version used on Remix - Refer to step 1.

  6. Optimization used on Remix- Refer to step 1; leave as 0 if you didn't optimize the code, 1 if you did

  7. Runs used - add the optimization runs you used. Leave as 200 if not applicable.

  8. License type - choose your license type if not specified leave as 1.

  9. API key - Keep the placeholder, as an API key is not required for verification.

  10. EVM version used on Remix- Refer to step 1.

  11. Constructor arguments: if not used remove from the params

Now, proceed by clicking "send"; this action will initiate the verification process.

After submitting the API request, assuming all values are correctly formatted, you should receive the following output. Now, take note of the “result” value, as we will use it to verify the successful completion of the process.

https://ibb.co/6bXbXSm
https://ibb.co/6bXbXSm

🔹 Now, proceed to the other API call, "checkverificationStatus," and paste the result output from the previous API call (you don’t need an API key so leave the placeholder).

inspect the URL; the imported one is tailored for verification on the Avalanche Fuji testnet. Adjust the URL to match the desired chain. For instance, if verification on the Avalanche mainnet is sought, replace "/testnet" with "/mainnet" and ensure the chain ID aligns with that of the Avalanche mainnet, which is typically 43114.

Click Send. This step will allow you to determine whether your contract has been verified, is in the queue, or if the verification has been rejected. You can see from the output that in this case the contract have been verified.

Go to our scanner - Snowtrace or Avascan and check the contract section.

Done!

https://ibb.co/gVVTVwH
https://ibb.co/gVVTVwH

⚠️ Common issues to watch for:

  • Ensure the compiler version, EVM, and other values precisely match those used during the contract deployment on the chain.

  • Confirm that the "contractname" is not the filename but the identifier used within the contract (refer to step 1 for clarification).

  • Check the URL and use the correct chainID and testnet/mainnet

  • You can verify your contract with other method, please check: Hardhat Verification - Snowtrace

  • If you have problem, please contact us on our Discord

Subscribe to Routescan.io
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.