resolveCompositeAbi

Resolves the ABI for a contract based on its bytecode. If the contract follows the plugin-pattern or dynamic pattern, it resolves the ABIs for the plugins and merges them with the root ABI. If the contract follows the base router pattern, it resolves the ABIs for the plugins and merges them with the root ABI. If the contract follows the diamond pattern, it resolves the ABIs for the facets and merges them with the root ABI.

Example

import { createThirdwebClient, getContract } from "thirdweb";
import { resolveCompositeAbiFromBytecode } from "thirdweb/contract";
import { ethereum } from "thirdweb/chains";
const client = createThirdwebClient({ clientId: "..." });
const myContract = getContract({
client,
address: "...",
chain: ethereum,
});
const abi = await resolveCompositeAbiFromBytecode(myContract);
function resolveCompositeAbi(
contract: Readonly<ContractOptions<[]>>,
rootAbi?: Abi,
resolveSubAbi?: (
contract: Readonly<ContractOptions<[]>>,
) => Promise<Abi>,
): Promise<Abi>;

Parameters

The contract for which to resolve the ABI.

Type

let contract: Readonly<ContractOptions<[]>>;

The root ABI to use for the contract. If not provided, it resolves the ABI from the contract's bytecode.

Type

let rootAbi: readonly Array<(AbiConstructor) | (AbiError) | (AbiEvent) | (AbiFallback) | (AbiFunction) | (AbiReceive)>

A function to resolve the ABI for a sub-contract. If not provided, it uses the default ABI resolution logic.

Type

let resolveSubAbi: (
contract: Readonly<ContractOptions<[]>>,
) => Promise<Abi>;

Returns

let returnType: readonly Array<(AbiConstructor) | (AbiError) | (AbiEvent) | (AbiFallback) | (AbiFunction) | (AbiReceive)>

The resolved ABI for the contract.