Contract utilities

The SDK comes packed with a few utilities that are useful beyond developing web3 applications.

Contract Verification

Verify a contract on a given block explorer via the sdk.verifier object.

const contractAddress = "0x...";
const explorerAPIUrl = ""; // e.g. https://api.etherscan.io/api
const explorerAPIKey = ""; // Generate API key on the explorer
await sdk.verifier.verifyContract(
contractAddress,
explorerAPIUrl,
explorerAPIKey,
);

Get the ABI of a contract

The SDK ABI resolution is useful in many situations, you can access the resolved ABI from any contract like so:

const contract = await sdk.getContract("0x...");
const ABI = contract.abi;

Getting all functions and events definitions from a contract

Get parsed function and event definitions from a contract:

const contract = await sdk.getContract("0x...");
const functions = await c.publishedMetadata.extractFunctions();
const events = await c.publishedMetadata.extractEvents();

Getting the sources of a contract

Get the solidity sources of a contract:

const contract = await sdk.getContract("0x...");
const sources = await contract.publishedMetadata.extractSources();

Getting the implementation address of a Proxy

Resolve the implementation address and bytecode of a given proxy contract. Supports a wide variety of proxy standards.

const { address, bytecode } = await resolveImplementation(
"0x...", // the proxy address
sdk.getProvider(),
);
console.log("Implementation address", address);