https://instance_base_url/api?module=contract

Get a list of contracts

listcontracts List sorted in ascending order based on the time a contact was first indexed by the explorer. With filters `unverified(2)` the results will not be sorted for performance reasons. Example:
https://instance_base_url/api
   ?module=contract
   &action=listcontracts
ParameterDescription
pageoptional nonnegative integer representing the page number used for pagination. ‘offset’ must also be provided.
offsetoptional nonnegative integer representing the max number of records to return when paginating. ‘page’ must also be provided.
filteroptional string verified|unverified|empty, or 1|2|3 respectively. Returns contracts with the requested status.
verified_at_start_timestampoptional unix timestamp Represents the starting timestamp for verified contracts. Only used with verified filter.
verified_at_end_timestampoptional unix timestamp Represents the ending timestamp for verified contracts. Only used with verified filter.

Get ABI for a verified contract

getabi Also available through a GraphQL addresses query. Example:
https://instance_base_url/api
   ?module=contract
   &action=getabi
   &address={addressHash}
ParameterDescription
addressstring containing the address hash.

Get contract source code for a verified contract

getsourcecode Also available through a GraphQL addresses query. Example:
https://instance_base_url/api
   ?module=contract
   &action=getsourcecode
   &address={addressHash}
ParameterDescription
addressstring containing the address hash.

Get contract creator address hash and creation transaction hash

getcontractcreation Returns contract creator and transaction hash. Up to 10 contracts at the one request Example:
https://instance_base_url/api
   ?module=contract
   &action=getcontractcreation
   &contractaddresses={addressHash},{addressHash}
ParameterDescription
contractaddressesstring containing address hashes, separated by ,

Verify a contract with its source code and contract creation information

verify Example:
https://instance_base_url/api
   ?module=contract
   &action=verify
   &addressHash={addressHash}
   &name={name}
   &compilerVersion={compilerVersion}
   &optimization={false}
   &contractSourceCode={contractSourceCode}
Curl Post Example
curl -d '{"addressHash":"0xc63BB6555C90846afACaC08A0F0Aa5caFCB382a1","compilerVersion":"v0.5.4+commit.9549d8ff", "contractSourceCode":"pragma solidity ^0.5.4; contract Test { }","name":"Test","optimization":false}' -H "Content-Type: application/json" -X POST "https://blockscout.com/poa/sokol/api?module=contract&action=verify"
On successful submission you will receive a guid as a receipt. Use this with checkverifystatusto view verification status.
ParameterDescription
addressHashstring containing the address hash of the contract.
namestring containing the name of the contract.
compilerVersionstring containing the compiler version for the contract.
optimizationenum whether or not compiler optimizations were enabled 0=false, 1=true
contractSourceCodestring containing the source code of the contract.
constructorArgumentsoptional string constructor argument data provided.
autodetectConstructorArgumentsoptional boolean whether or not automatically detect constructor argument.
evmVersionoptional EVM version for the contract.
optimizationRunsoptional number of optimization runs used during compilation
library1Nameoptional string name of the first library used.
library1Addressoptional string address of the first library used.
library2Nameoptional string name of the second library used.
library2Addressoptional string address of the second library used.
library3Nameoptional string name of the third library used.
library3Addressoptional string address of the third library used.
library4Nameoptional string name of the fourth library used.
library4Addressoptional string address of the fourth library used.
library5Nameoptional string name of the fifth library used.
library5Addressoptional string address of the fifth library used.

Verify a contract through Sourcify

verify_via_sourcify
  1. if a smart contract is already verified on Sourcify, it will automatically fetch the data from the repo
  2. otherwise you need to upload source files and JSON metadata file(s).
Example:
https://instance_base_url/api
 ?module=contract
 &action=verify_via_sourcify
 &addressHash={addressHash}

POST body example

--6e1e4c11657c62dc1e4349d024de9e28
Content-Disposition: form-data; name="addressHash"

0xb77b7443e0F32F1FEBf0BE0fBd7124D135d0a525

--6e1e4c11657c62dc1e4349d024de9e28
Content-Disposition: form-data; name="files[0]"; filename="contract.sol"
Content-Type: application/json

...Source code...

--6e1e4c11657c62dc1e4349d024de9e28
Content-Disposition: form-data; name="files[1]"; filename="metadata.json"
Content-Type: application/json

...JSON metadata...

--6e1e4c11657c62dc1e4349d024de9e28--
ParameterDescription
addressHashstring containing the address hash.
filesarray with sources and metadata files

Verify a vyper contract with its source code and contract creation information

verify_vyper_contract Example
https://instance_base_url/api
 ?module=contract
 &action=verify_vyper_contract
 &addressHash={addressHash}
 &name={name}
 &compilerVersion={compilerVersion}
 &contractSourceCode={contractSourceCode}
curl POST example
curl --location --request POST 'http://localhost:4000/api?module=contract&action=verify_vyper_contract' --form 'contractSourceCode="SOURCE_CODE"' --form 'name="Vyper_contract"' --form 'addressHash="0xE60B1B8bD493569a3E945be50A6c89d29a560Fa1"' --form 'compilerVersion="v0.2.12"'
ParameterDescription
addressHashstring containing the address hash of the contract.
namestring containing the name of the contract.
compilerVersionstring containing the compiler version for the contract.
contractSourceCodestring containing the source code of the contract.
constructorArgumentsstring constructor argument data provided.

Verify a contract with Standard input JSON file

verifysourcecode Example
https://instance_base_url/api
 ?module=contract
 &action=verifysourcecode
 &codeformat={solidity-standard-json-input}
 &contractaddress={contractaddress}
 &contractname={contractname}
 &compilerversion={compilerversion}
 &sourceCode={sourceCode}
solidity-single-file:
curl --location 'localhost:4000/api?module=contract&action=verifysourcecode' \
--form 'contractaddress="0xDc2082945d55596bf39F362d9EC0F7F65eDBB9DD"' \
--form 'sourceCode="// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

contract Storage {
    uint256 number;

    function store(uint256 num) public {
        number = num;
    }

    function retrieve() public view returns (uint256){
        return number;
    }
}"' \
--form 'contractname="Storage"' \
--form 'codeformat="solidity-single-file"' \
--form 'compilerversion="v0.8.17+commit.8df45f5f"' \
--form 'optimizationUsed="1"' \
--form 'runs="199"' \
--form 'constructorArguements=""' \
--form 'evmversion="london"' \
--form 'libraryname1="qwe"' \
--form 'libraryaddress1="0xDc2082945d55596bf39F362d9EC0F7F65eDBB9DD"'
--form 'licenseType=0'
ParameterDescription
codeformatFormat of sourceCode (solidity-standard-json-input or solidity-single-file)
contractaddressstring containing the address hash of the contract.
contractnamestring name of the contract. It an be an empty string(""), just the contract name(“ContractName”), or a filename and contract name(“contracts/contract_1.sol:ContractName”)
compilerversionstring containing the compiler version for the contract.
sourceCodestring standard input json or flattened solidity code
optimizationUsedcould be 0, false, 1, true. Should be set when codeformat=solidity-single-file
runsinteger is equal to optimization runs number set on compilation. Should be set when optimizationUsed is 1 or true
evmversionstring EVM version. Should be set when codeformat=solidity-single-file
constructorArgumentsoptional string constructor argument data provided.
autodetectConstructorArgumentsoptional boolean whether or not automatically detect constructor argument.
licenseTypestring or number representing the license type.
License type“See available license types.”

Return status of a verification attempt

checkverifystatus
guid is received as a receipt from the verifysourcecode method.
Example
https://instance_base_url/api
 ?module=contract
 &action=checkverifystatus
 &guid={identifierString}
ParameterDescription
guidstringused for identifying verification attempt
Return Options: Pending in queue | Pass - Verified | Fail - Unable to verify | Unknown UID

Verify proxy contract

verifyproxycontract Example
https://instance_base_url/api
 ?module=contract
 &action=verifyproxycontract
 &address={addressHash}
ParameterDescription
addressstring containing the address hash of the contract

Return status of a proxy contract verification attempt

checkproxyverification
guid is received as a receipt from the verifyproxycontract method.
Example
https://instance_base_url/api
 ?module=contract
 &action=checkproxyverification
 &guid={identifierString}
ParameterDescription
guidstringused for identifying verification attempt