Bnbscan

Bnbscan contract verification matches source code to deployed bytecode

Bnbscan contract verification checks whether a contract's source code and compiler settings reproduce its deployed bytecode on BNB Smart Chain. A successful match publishes readable code for inspection. The required inputs come from the original deployment build, including constructor arguments where applicable. Submitting those materials starts a verification request; completion requires a successful verification result.

· updated

Jump to a section

A compiler selection changes how the explorer rebuilds submitted source, while a published ABI describes the contract's interface. Neither a submission receipt nor readable source establishes the safety of every function.

Source files, compiler settings, and deployed bytecode

A deployed contract supplies the comparison target, while its source files and build settings supply the material needed to reproduce that target. Bytecode is the compiled code on the network. Source files express the contract's logic in a programming language, and the compiler translates them using a particular configuration. Verification connects these representations at the selected contract address. A contract name alone doesn't identify the deployment, and a familiar source file doesn't establish a match.

The verification input needs the deployed contract's address, the intended contract within the source, and the original compiler version. Optimizer settings and the target Ethereum Virtual Machine (EVM) version also affect the build. Constructor inputs belong to the deployment context when the contract used them. These inputs serve different purposes: the address selects the comparison target, while the build materials determine what the verifier compiles. Replacing an original setting with a convenient default can prevent reproduction.

Published code and the contract interface

A verified contract exposes source code and compiler information alongside its application binary interface (ABI). Software uses the ABI to encode contract calls and decode events. Readable source supports inspection of the logic behind those calls. The interface and the implementation therefore answer different questions: the ABI describes how to communicate with a contract, while the source explains the submitted program's behavior.

The source-code lookup action, getsourcecode , returns published source and associated settings. The narrower getabi action returns the interface without that surrounding material. During an investigation of token approvals, code inspection can explain a spending function's logic. The owner's current allowance remains a separate state value in the token contract. Publishing source doesn't establish that value or change an existing spending permission.

Solidity source formats and complete build inputs

The Solidity API's source-format selector determines how a submission carries its files and build configuration. With solidity-standard-json-input , the compiler's Standard JSON input contains source files, imported code, and build settings together. This format suits projects with imports or non-default settings. The verifier needs the actual source contents and configuration required to reproduce the deployment, so selecting JSON doesn't compensate for missing dependencies.

The solidity-single-file format expects a flattened Solidity file without unresolved external imports. Its source text doesn't embed the complete compiler configuration. Separate fields carry optimizer settings, including optimizationUsed and runs . Flattening and Standard JSON are supported ways to supply a Solidity program, although they package its information differently. The format selector must describe the material submitted in sourceCode ; it doesn't convert that material into another format.


Does Standard JSON need separate optimizer fields?

A Solidity Standard JSON submission carries optimizer settings inside its compiler input, so separate optimizer fields aren't required for that format. In this hypothetical case, a deployment project contains imported files and explicit optimizer settings. The developer prepares the verification request without standalone optimizer fields.

The project's Standard JSON input already contains the source files and the deployment's optimizer configuration. With codeformat set to solidity-standard-json-input , those embedded settings supply the optimizer information. The separate optimizationUsed , runs , and evmVersion fields aren't necessary. The contract address, full compiler version, and other applicable submission inputs still have their own roles.

A flattened version of the same project would need separate compiler settings because the Solidity text doesn't carry them. In particular, the single-file format requires optimizationUsed . The Standard JSON request therefore contains the optimizer information despite omitting that standalone field. The verifier must still compile the submitted materials and establish the bytecode match.


Compiler versions and constructor arguments

The compiler version must match the deployment build, including the full version string the verification service accepts. Choosing a newer compiler doesn't establish compatibility with an older deployment's bytecode. Optimizer enablement and its run setting must also match the original configuration. The EVM target belongs to that configuration too. Use the compiler's default only when it describes the deployment build; retain an explicit target when the original build selected one.

Constructor arguments require the values the deployment actually supplied, encoded as hexadecimal using the ABI. Current contract state isn't a substitute for those original arguments. If the constructor took no arguments, leave the argument field empty. Keep the source build and deployment arguments together when preparing the submission, since matching one doesn't resolve an error in the other.

Bnbscan contract verification: Compiler versions and constructor arguments - illustration

View image file


Verification requests and final results

Verification can start in the explorer's browser form or through supported development tools. The Solidity API workflow submits source through the verifysourcecode action using an HTTP POST request. The contract address must identify a deployment on the selected chain. An Etherscan API key authenticates the V2 request. Those request credentials and deployment details have separate roles; neither substitutes for the source materials.

A successful verification submission returns a request identifier for the queued verification job. The response can contain status equal to 1 and an OK message while result holds that identifier. These fields describe acceptance of the submission.

The checkverifystatus action uses the identifier to retrieve the verification outcome. A job can remain in processing when the first status request arrives. Further status checks track the same queued job. Elapsed time alone doesn't establish a successful match.

The completed success result reads Pass - Verified . The Contract tab then displays the verified checkmark, and the published source becomes available through the source-code lookup.

A failed result supplies a reason for the unsuccessful verification. Correcting the relevant input and submitting again creates another attempt at reproducing the deployment. A status check only reads an existing request's progress; it doesn't correct its compiler version, source contents, or deployment arguments.


Build mismatches and targeted corrections

A bytecode mismatch means the submitted build hasn't reproduced the deployed contract under the supplied conditions. Compiler failures occur earlier, when the verifier can't compile the submitted program. Their remedies differ. Missing source dependencies require complete source inputs, while a valid compilation with different output calls for comparison against the original compiler settings and deployment materials. Editing working logic to silence a verification error can move the submission further from the deployed program.

Metadata settings can also cause a mismatch even when the main logic appears identical. Standard JSON supports an explicit bytecode metadata-hash setting; other submission formats use compiler defaults for that setting. A deployment with a non-default choice therefore needs its original setting carried into the verification input. Where a build uses linked libraries, their names and deployed addresses must match too. Library names are case sensitive, and an imported source file alone doesn't supply a missing linked-library address.

Network scope and the V2 API

Verification applies to a particular contract address and network, even when another network has a deployment from the same source. BNB Smart Chain mainnet uses chain ID 56 . Verification on another chain doesn't verify this deployment automatically. The legacy explorer API is deprecated, and Etherscan API V2 supplies the supported programmatic interface. This migration changes the API route and credentials; it doesn't mean the explorer's source-verification function has ended.

Proxy code and implementation verification

A proxy requires attention to its own address and the implementation address its calls resolve to. Published proxy code alone doesn't describe every function in that implementation. The V2 proxy workflow uses verifyproxycontract , followed by checkproxyverification to retrieve the outcome. Its optional expectedimplementation parameter enforces an expected implementation address during verification. Source publication and the proxy-to-implementation relationship remain distinct checks, so inspect the code relevant to each address.

Verified source and a security review

A completed source match establishes a relationship between published code and a deployment, without evaluating every consequence of the program's behavior. An approval function can follow its written logic while granting authority the token owner didn't intend to grant. Reading that logic helps explain the permission. The verified label doesn't decide whether authorizing it fits the intended transaction, and it doesn't execute or revoke that authorization.

A security review examines the behavior and weaknesses of the code within its stated scope. The useful comparison concerns the same deployment and, where relevant, its implementation. Source verification addresses whether the published build matches the deployed code. A security review addresses what that code permits and where its assumptions can fail. A report about different source or a different implementation doesn't assess the code merely because both share a project name.

Things people ask about Bnbscan contract verification

Which contract name belongs in a multi-contract verification request?

The request must name the deployed contract you intend to verify, including its source-file path when the format requires it. For Standard JSON input, contractname combines that path and the contract identifier with a colon. Selecting an imported dependency instead targets the wrong compilation output.

Do I need a paid API plan for BNB Smart Chain contract verification?

Contract-verification services remain available on the Free API tier across supported networks, including BNB Smart Chain. This exception also covers verified source-code and ABI endpoints. It doesn't extend free access to unrelated balance or transaction-history queries on that network, and API requests still require appropriate credentials.

Can Hardhat, Foundry, or Remix submit contract verification materials?

Hardhat, Foundry, and Remix have supported verification workflows. Using an existing toolchain can supply deployment build information without manually restating every setting. The workflow still needs the intended network, contract address, and matching compilation inputs; the choice of tool doesn't relax the bytecode-matching requirement.

What happens if the source code is already verified?

A source-already-verified response indicates the explorer already has an exact match for that deployment. Confirm the selected address and network before treating it as a problem. Verification on another chain remains separate, and changing valid source isn't a remedy for an existing successful match.

Why does a source lookup return success for an unverified address?

A successful source lookup can report status 1 even when the address has no verified source. In that case, SourceCode is empty and ABI contains the message Contract source code not verified. Check the returned fields before treating the response as usable source or interface data.

Is Solidity verification the correct submission type for Vyper code?

Vyper contracts require the Vyper verification action and its language-specific compiler inputs. Solidity's single-file and Standard JSON selectors describe the Solidity workflow. Choose the submission type for the language of the deployed contract; changing the format label doesn't translate its source into another language.

What does the license selection change during verification?

The licenseType field associates a selected open-source license with the published source code. It doesn't select the compiler or change deployed contract behavior. Choose the license applicable to the actual source materials; the verification checkmark doesn't establish ownership of that code.

Should a verification upload contain private deployment credentials?

Private keys and recovery phrases don't belong in verification source uploads. Verification publishes source for public inspection, so keep deployment credentials outside that material. An API key belongs in the request's authentication field, separate from the source code the explorer makes readable.