Reference

How verification works

On this page

Verification has three parts: build metadata compiled into the contract, a hosted service that rebuilds and compares, and a registry contract that stores the result for explorers to read. This page follows one request through each part, as implemented in the public source on 25 November 2026.

From API to registry to NearBlocks

  1. The contract describes its own build. A contract built with cargo-near exposes contract_source_metadata (NEP-330). Its build_info names the Git source snapshot, the builder image by digest, the build command and the contract path. Version 1.2.0 of the standard added build_info, and NEAR's verifier library requires it. near-verify-rs validation
  2. A request starts the rebuild at one block. NearBlocks sends the account ID and network to POST /api/verify/rust on api-v2.sourcescan.dev. The service reads the metadata and pins the code comparison to the block hash returned with it. It reads the deployed code hash there, checks that the source snapshot is a public Git commit it can fetch, then runs near contract verify deployed-at ACCOUNT_ID network-config NETWORK at-block-hash BLOCK_HASH. NEAR CLI reads the same metadata and code, rebuilds in the pinned image and compares. Without a blockId, or with blockId 0, the metadata read starts from the latest finalized block; NearBlocks sends none. A positive blockId in a direct API request selects a height the verifier's RPC nodes must still serve. A rebuild can take several minutes. Verify controller and CLI call
  3. A match is archived and recorded. When NEAR CLI reports identical code and its hash equals the deployed hash at that block, the service pins the repository snapshot to IPFS and writes the account's record: the code hash, that block's height, language rust and the IPFS CID. It then answers Contract verified successfully. If the account's record already has the same hash, it answers Code hash didn't change and writes nothing. Each account has one record, and a new write replaces it. The registry does not require block heights to increase, so a request for an earlier block, or a slower request that finishes later, can replace a newer record with one for code the account no longer runs. Record write and registry
  4. Explorers compare when you look. NearBlocks looks records up by the deployed code hash. The SourceScan explorer reads the account's own record and checks the deployed code when you open its contract page. Nothing updates a record when the account is redeployed. See after a redeploy.

The registries are v2-verifier.sourcescan.near on mainnet and v2-verifier.sourcescan.testnet on testnet. Their read methods are listed in the registry reference.

NearBlocks integration

NearBlocks reads SourceScan data on its Contract Code page.

SourceScan explorer

The SourceScan explorer lists registry records by network without checking deployed code. When you open a record, your browser reads the current finalized code hash through a public RPC endpoint and compares it with the recorded hash. The Verified source tab reads from the recorded IPFS CID. The Build tab reads live metadata, which can also determine the Repository link. After a redeploy, that metadata may refer to a different build than the archived source. Older sourcescan.dev links forward to the same path on app.sourcescan.dev. See labels and their meaning. Explorer source

Source snapshots

The registry record identifies the archived source. The contract's metadata identifies the Git snapshot for its deployed build.

Use that form: a public repository over HTTPS, then ?rev= and the full 40-character commit SHA. The verifier's checks before the rebuild are looser than the rebuild itself.

NEP-330 also allows other references, such as ipfs:// snapshots. The hosted verifier rejects them.

If the IPFS gateway is unavailable, the Git snapshot is still a usable copy as long as it exists, and the reverse is also true.

Who can write records

Only the registry's owner account can add, replace or remove verification records, so a record is an attestation by SourceScan's service. The registry also has public methods for votes and comments on records. They are separate from verification and do not change a record's code hash or CID. Registry source

To check a result without relying on SourceScan, rebuild it yourself.