Problem on contract verification

When trying to verify my contract, I encounter this problem:
ENOENT: no such file or directory, open ‘/app/dist/services/codeverification/0x598228643d6faa1b5569c3d996cb8cf8ca1fdb92/build/contracts/equals9.json’

There is nothing in the docs about it. Am I doing something wrong?

(1) Make sure the Contract Name is exactly the contract name. Remove any comments in the code, and if you used an optimizer, change it to yes. Mostly the default is Yes and 200.
(2) Flatten the code (this will replace the library used by the bytecode of the library). For VS code you can use this: Solidity Contract Flattener - Visual Studio Marketplace
(3) Remove comments and blank lines using https://solidity-comment-cleaner.netlify.app/

3 Likes

That did the trick, thanks. Recently, I’ve had to verify contracts again. If anyone is wondering, the steps that did work for me were:
1- Flatten the contract with npx hardhat flatten.

2- Remove Solidity comments with: https://solidity-comment-cleaner.netlify.app/

3- Remove all pragma solidity <version> from the contract except the one on top.

4- Use the exact same compiler version used to build the contract.

1 Like