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
- The contract describes its own build. A contract built with cargo-near exposes
contract_source_metadata(NEP-330). Itsbuild_infonames the Git source snapshot, the builder image by digest, the build command and the contract path. Version 1.2.0 of the standard addedbuild_info, and NEAR's verifier library requires it. near-verify-rs validation - A request starts the rebuild at one block. NearBlocks sends the account ID and network to
POST /api/verify/rustonapi-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 runsnear 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 ablockId, or withblockId0, the metadata read starts from the latest finalized block; NearBlocks sends none. A positiveblockIdin 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 - 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
rustand the IPFS CID. It then answersContract verified successfully. If the account's record already has the same hash, it answersCode hash didn't changeand 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 - 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.
- Status. NearBlocks calls the contract's
contract_source_metadataand the registry'sget_contracts_by_code_hash, takes the first record returned, and shows Contract Source Code Verified when that record's hash equals the deployed hash. Otherwise it shows its Verify and Publish prompt, including when the registry call fails. It shows neither when it gets no NEP-330 metadata, which also happens when the metadata call fails or takes longer than 5 seconds. Code page - Source files. NearBlocks lists the record's CID through
https://api.sourcescan.dev/api/ipfs/structure, keeps.rs,.tomland.lockfiles undercontract_path, skips the.git,.github,.cargo,.vscode,node_modulesandtargetfolders, and loads each file by its own IPFS hash. If loading fails, it shows Failed to load source files or No Rust source files found. Source viewer - Verify page.
/verify-contract?account=ACCOUNT_IDshows the registry, standard, language and build environment, and its Verify Contract button sendsaccountIdandnetworkIdto SourceScan. The button is disabled when the metadata lacks NEP-330,build_environmentorsource_code_snapshot. The language is fixed to Rust. Verify form
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.
- IPFS archive. At verification time, SourceScan pins the source snapshot to its IPFS node and stores the CID in the record. A CID is derived from the content, so the same CID always identifies the same files. Reads go through
api.sourcescan.dev. How long SourceScan keeps content pinned is not published. - Git snapshot.
source_code_snapshotin the metadata is a repository URL with a commit. cargo-near writes it frompackage.repositoryand the pushed commit, asgit+https://github.com/OWNER/REPO?rev=COMMIT. It is the input the verifier rebuilt from. The repository owner controls whether it stays available.
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.
- Precheck. The snapshot must start with
git+, use HTTPS or SSH with no user name or password in an HTTPS URL, and pin a full commit as?rev=SHAor#SHA. Thegit@host:owner/reposhorthand also passes. Snapshot checks - Rebuild. NEAR CLI takes the commit only from
?rev=and cannot parse thegit@host:owner/reposhorthand. A fragment-only pin or shorthand URL can pass the precheck's format rules, but it cannot work for this rebuild. NEAR CLI 0.31.1 and snapshot parser
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.