resolveContractAbi

Resolves the ABI (Application Binary Interface) for a given contract. If the ABI is already cached, it returns the cached value. Otherwise, it tries to resolve the ABI from the contract's API. If that fails, it resolves the ABI from the contract's bytecode.

Example

import { createThirdwebClient, getContract } from "thirdweb";
import { resolveContractAbi } from "thirdweb/contract";
import { ethereum } from "thirdweb/chains";
const client = createThirdwebClient({ clientId: "..." });
const myContract = getContract({
client,
address: "...",
chain: ethereum,
});
const abi = await resolveContractAbi(myContract);
function resolveContractAbi(
contract: Readonly<ContractOptions<abi>>,
contractApiBaseUrl: string,
): Promise<abi>;

Parameters

The contract for which to resolve the ABI.

Type

let contract: Readonly<ContractOptions<abi>>;

The base URL of the contract API. Defaults to "https://contract.thirdweb.com/abi".

Type

let contractApiBaseUrl: string;

Returns

let returnType: Promise<abi>;

A promise that resolves to the ABI of the contract.