Similarity verification
Similarity verification allows verifying a contract by comparing its onchain bytecode with existing bytecodes in the Sourcify database. If similar candidates are found in the database, the existing compilation inputs and outputs for each candidate are used to verify the target contract until a match is found.
Sourcify supports similarity verification via the /v2/verify/similarity API endpoint, you can find more information in the APIs documentation.
Use cases
- Block explorers can try to use similarity search if users visit a non-verified contract
- A similarity search API call can be triggered after each contract creation event by listening a chain's events.
Implementation details
Sourcify uses the first 75 bytes of the target runtime bytecode to search the bytecodes table for similar contracts. The process is inspired by Blockscout's Ethereum Bytecode Database Microservice. The first 75 bytes are sufficient to identify a contract without interfering with immutables or other values that may differ between deployments of the same contract. After a list of candidates is returned, the target contract goes through the standard Sourcify verification flow for each candidate’s sources and settings.