API Documentation
Table of Contents and resources
- Basic usage
- Server API Documentation
- 4byte (Signature) Service API Documentation
- Documentation in JSON format for LLMs
Basic usage
Verification
The main Sourcify API for verification is /v2/verify/{chainId}/{address}, it either returns a verificationId or an error. The status of the verification process can be tracked by /v2/verify/${verificationId}. For additional details, please check the documentation below.
- curl
- Javascript
verification_result=$(
curl -sS -X POST \
'https://sourcify.dev/server/v2/verify/11155111/0x2738d13E81e30bC615766A0410e7cF199FD59A83' \
-H 'Content-Type: application/json' \
--data-raw '{"stdJsonInput":{"language":"Solidity","sources":{"contracts/Storage.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ncontract Storage {\n uint256 number;\n\n function setNumber(uint256 newNumber) public {\n number = newNumber;\n }\n\n function getNumber() public view returns (uint256) {\n return number;\n }\n}\n"}},"settings":{"optimizer":{"enabled":false,"runs":200}}},"compilerVersion":"0.8.7+commit.e28d00a7","contractIdentifier":"contracts/Storage.sol:Storage","creationTransactionHash":"0xb6ee9d528b336942dd70d3b41e2811be10a473776352009fd73f85604f5ed206"}'
)
verification_id=$(echo "$verification_result" | jq -r '.verificationId // empty')
if [ -n "$verification_id" ]; then
curl -sS \
"https://sourcify.dev/server/v2/verify/${verification_id}"
else
echo "$verification_result"
fi
const verificationResponse = await fetch(
"https://sourcify.dev/server/v2/verify/11155111/0x2738d13E81e30bC615766A0410e7cF199FD59A83",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
stdJsonInput: {
language: "Solidity",
sources: {
"contracts/Storage.sol": {
content: "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ncontract Storage {\n uint256 number;\n\n function setNumber(uint256 newNumber) public {\n number = newNumber;\n }\n\n function getNumber() public view returns (uint256) {\n return number;\n }\n}\n",
},
},
settings: {
optimizer: {
enabled: false,
runs: 200,
},
},
},
compilerVersion: "0.8.7+commit.e28d00a7",
contractIdentifier: "contracts/Storage.sol:Storage",
creationTransactionHash: "0xb6ee9d528b336942dd70d3b41e2811be10a473776352009fd73f85604f5ed206",
}),
}
);
const verificationResult = await verificationResponse.json();
const { verificationId } = verificationResult;
if (verificationId) {
const jobResponse = await fetch(
`https://sourcify.dev/server/v2/verify/${verificationId}`
);
const jobResult = await jobResponse.json();
console.log(jobResult);
} else {
console.log(verificationResult);
}
Contract Lookup
Verified contracts data can be fetched using the /v2/contract/{chainId}/{address}?fields=all API. For the full list of fields and additional parameters please check the documentation below.
- curl
- Javascript
curl -sS \
'https://sourcify.dev/server/v2/contract/11155111/0x2738d13E81e30bC615766A0410e7cF199FD59A83?fields=all'
const response = await fetch(
"https://sourcify.dev/server/v2/contract/11155111/0x2738d13E81e30bC615766A0410e7cF199FD59A83?fields=all"
);
const contract = await response.json();
console.log(contract);
Server API Documentation
Loading Swagger UI...
4byte (Signature) Service API Documentation
Loading Swagger UI...