When I pass it to the verification process with a singe file on PolygonScan it brings me this. It founds the exact code match but it is not being verifying it
I resolved it. I copied the Bytecode paste it https://abi.hashex.org/ used the HEX data and import it. That is the solution hope it helps a lot of developers in the future.
Finally I can launch https://fataperocketcrew.com/
Hi,
Yeah, I had used the flattened file and Im getting the same error as yours. Im using hardhat to compile and deploy.
But Im confused where to paste the ABI and where and how I should use the abi.hashex.org
Hey @Shinoy_K, not sure if you're still having this error. This thread helped me solve this issue. The error: But we were unable to locate a matching bytecode (err_code_2) was occurring because I was trying to verify a contract that was deployed by another contract. In order to properly verify this contract I had to input the ABI encoded constructor parameters into the Constructor Arguments section in the contract verification form. This is right below the solidity source code input.
The https://abi.hashex.org/ tool lets you enter these arguments and it generates the ABI encoded params. I used the section underneath Or enter these parameters manually. In my case I had to encode the constructor function type. For each argument I set the type on the left side (using the dropdown) and then input the value on the right side. So if I had an argument of owner that was of type Address, I would set Address using the dropdown on the left and then paste in the actual address value that was passed in during contract creation.
Right below these inputs you will see a text box containing the ABI encoded params (a long string of numbers and letters), you can paste this into the Constructor Arguments section and it should verify the contract properly. I hope this clarification helps you or anyone else facing this issue! Thanks!
I encountered some similar issues with contract verification on Polygonscan, for a customizable ERC20 token factory that imports OpenZeppelin's ERC20. Here's a summary of what I found
I initially compiled the the contract with hardhat. In order to perform contract verification on Polygonscan, I had to flatten the import. I used the npx hardhat flatten contract.sol > output.sol command and inputted the the flattened contract, but kept getting the issue below, similar to the OP:
After numerous attempts at flattening and re-attempting verification, I realized that the entire flow would work if compiled by Remix instead of Hardhat.
So ultimately, I ended up using Remix to:
recompile my token factory contract
use that new ABI and bytecode instead for my token minter dapp (as the contract factory)
use REMIX to flatten it
complete contract verification on Polygonscan successfully
So now the verification works now because the flattened source code was generated from Remix, as was the original ABI and bytecode.
My suspicion is that there could be a discrepancy between the solidity compiler version with the OpenZeppelin contract and the actual contract when doing it with hardhat.
Other things to make sure are consistent would be the solc version, optimization, license, etc.
Thank you for sharing @juwu. Flattening is not the best way to verify a contract. If you deployed with Hardhat, did you try the hardhat-etherscan plugin? Note that despite the name it supports Polygonscan as well.
People having issues with verification should consult the main resource guide:
@frangio thanks for the reply! I haven't tried the etherscan plugin partially because the UI/website approach was the one that my users tried and flagged to me.
Also, most resources I came across suggest going the website route on etherscan/polygonscan. It'd be nice to have a standard -- either all CLI or all web