Skip to content

fix: VerifyAll fails when contract name differs from source file name#411

Open
rin-st wants to merge 1 commit intomainfrom
fix/verify-all-artifact-path
Open

fix: VerifyAll fails when contract name differs from source file name#411
rin-st wants to merge 1 commit intomainfrom
fix/verify-all-artifact-path

Conversation

@rin-st
Copy link
Copy Markdown
Member

@rin-st rin-st commented Apr 16, 2026

Summary

  • VerifyAll.s.sol's _getCompiledBytecode assumed compiled artifacts live at out/{contractName}.sol/{contractName}.json, but Foundry organizes artifacts by source file name, not contract name. When they differ (e.g. contract ORA defined in OracleToken.sol), the script reverts with a file-not-found error.
  • The fix tries the default path first, then falls back to searching the out/ directory via find to locate the correct artifact.

How to test

  1. Create a project with a contract whose name differs from its source file name (e.g. contract ORA inside OracleToken.sol)
  2. Deploy to a testnet: yarn deploy --network sepolia
  3. Run yarn verify --network sepolia
  4. Before fix: reverts with vm.readFile: failed to open file "...out/ORA.sol/ORA.json": No such file or directory
  5. After fix: verification proceeds correctly, finding the artifact at out/OracleToken.sol/ORA.json

Things to look out for

  • The function signature changes from internal view to internal (dropping view) because the fallback path uses tryFfi. The caller _verifyContract is already non-view, so this is safe.
  • The find fallback excludes build-info/ to avoid matching the wrong JSON files.

Made with Cursor

`_getCompiledBytecode` assumed the compiled artifact path matches
`out/{contractName}.sol/{contractName}.json`, but Foundry organizes
artifacts by source file name. When a contract name differs from its
source file (e.g. contract `ORA` in `OracleToken.sol`), verification
reverts with a file-not-found error.

Try the default path first, then fall back to searching the `out/`
directory for the correct artifact.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant