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:
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