verifyContract

Verifies a contract by performing the following steps:

  • Resolves the implementation of the contract.

  • Extracts the IPFS URI from the contract bytecode.

  • Downloads the contract source code from the IPFS URI.

  • Fetches the source files from the compiler metadata.

  • Compiles the contract source code using the Solidity compiler.

  • Fetches the constructor parameters if not provided.

  • Sends a request to the contract verification API to verify the contract source code.

Example

import { getContract } from "thirdweb/contract";
import { verifyContract } from "thirdweb/contract";
const contract = getContract({ ... });
const verificationResult = await verifyContract({
contract,
explorerApiUrl: "https://api.polygonscan.com/api",
explorerApiKey: "YOUR_API_KEY",
});
console.log(verificationResult);
function verifyContract(
options: VerifyContractOptions,
): Promise<string | Array<string>>;

Parameters

The options for contract verification.

Type

let options: VerifyContractOptions;

Returns

let returnType: Promise<string | Array<string>>;

A promise that resolves to the verification result.