Skip to main content

Attempt contract verification

  • The received address, chainId and compilerVersion parameters are updated serverside for each provided contract.
  • After updating, attempts verification of those contracts that:
    • are successfully validated (no source files missing, as per metadata)
    • have all their parameters specified (address, chainId, compilerVersion)
    • are included in the received object
  • The result of verification is available under the status property of every contract .
note

Session-based API is only meant for the sourcify.dev UI. Because it makes use of session cookies and it is not possible have Access-Control-Allow-Origin: * with credentials: true, meaning these endpoints can only be used on explicitly set domains on the browser. (e.g. sourcify.dev). Please use the verification API if you want Sourcify on your frontend.

URL : /session/verify-validated

Method : POST

{
"contracts": [
{
"address": "0x656d0062eC89c940213E3F3170EA8b2add1c0143",
"chainId": "100",
// optional
"contextVariables": {
"abiEncodedConstructorArguments": ...,
"msgSender": ...
},
//optional
"creatorTxHash": ...,
"verificationId": "0x3f67e9f57515bb1e7195c7c5af1eff630091567c0bb65ba3dece57a56da766fe"
}
]
}
  • contextVariables (optional) are used to simulate the contract creation by executing the contract's creation code with these variables. For example, if the contract sets the immutable owner to msg.sender, then the msgSender has to be provided for a match. These will be saved under the contract folder as context-variables.json later for the reproducability of the verification.
  • creatorTxHash (optional) the transaction that created the contract. Will be used to compare creation bytecodes if the contracts was created by a simple contract creation tx which contains the contract's creation bytecode. If left empty, the Sourcify server will fetch it from an API or block explorer given in sourcify-chains.ts. When the contract is verified with this field (or when it's fetched by the Sourcify server), the tx hash will be saved in creator-tx-hash.txt in the contract folder.

Responses

Assumptions for all example responses (except the last one) :

  • There is one pending contract with all source files, but no address or chainId.
  • Supplying the following minimum object (extra properties would be ignored):

Condition : The provided contract perfectly matches the one at the provided chainId and address.

Code : 200 OK

Content :

{
"contracts": [
{
"verificationId": "0x3f67e9f57515bb1e7195c7c5af1eff630091567c0bb65ba3dece57a56da766fe",
"compiledPath": "browser/1_Storage.sol",
"name": "Storage",
"compilerVersion": "0.6.6+commit.6c089d02",
"address": "0x656d0062eC89c940213E3F3170EA8b2add1c0143",
"chainId": "100",
"files": {
"found": ["browser/1_Storage.sol"],
"missing": []
},
"status": "perfect"
}
],
"unused": []
}

Condition : The contract at the provided chainId and address has already been verified at 2021-01-12T15:41:56.502Z.

Code : 200 OK

Content :

{
"contracts": [
{
"verificationId": "0x3f67e9f57515bb1e7195c7c5af1eff630091567c0bb65ba3dece57a56da766fe",
"compiledPath": "browser/1_Storage.sol",
"name": "Storage",
"compilerVersion": "0.6.6+commit.6c089d02",
"address": "0x656d0062eC89c940213E3F3170EA8b2add1c0143",
"chainId": "100",
"files": {
"found": ["browser/1_Storage.sol"],
"missing": []
},
"status": "perfect",
"storageTimestamp": "2021-01-12T15:41:56.502Z"
}
],
"unused": []
}

Condition : No pending contracts.

Code : 400 Bad Request

Content :

{
"error": "There are currently no pending contracts."
}