Contract

?module=contract

https://fonscan.io/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 `not_decompiled`(`4`) or `not_verified(4)` the results will not be sorted for performance reasons.

Example:

https://fonscan.io/api
   ?module=contract
   &action=listcontracts

Get ABI for a verified contract

getabi

Also available through a GraphQL addresses query.

Example:

https://fonscan.io/api
   ?module=contract
   &action=getabi
   &address={addressHash}

Get contract source code for a verified contract

getsourcecode

Also available through a GraphQL addresses query.

Example:

https://fonscan.io/api
   ?module=contract
   &action=getsourcecode
   &address={addressHash}

Verify a contract with its source code and contract creation information

verify

Example:

https://fonscan.io/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.

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://fonscan.io/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--

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

verify_vyper_contract

Example

https://fonscan.io/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"'

Verify a contract with Standard input JSON file

verifysourcecode

Example

https://fonscan.io/api
 ?module=contract
 &action=verifysourcecode
 &codeformat={solidity-standard-json-input}
 &contractaddress={contractaddress}
 &contractname={contractname}
 &compilerversion={compilerversion}
 &sourceCode={sourceCode}

Return status of a verification attempt

checkverifystatus

guid is received as a receipt from the verifysourcecode method.

Example

https://fonscan.io/api
 ?module=contract
 &action=checkverifystatus
 &guid={identifierString}

Last updated