Skip to main content

SmartContract class

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Custom contract dynamic class with feature detection

Example

import { ThirdwebSDK } from "@thirdweb-dev/sdk";

const sdk = new ThirdwebSDK(provider);
const contract = await sdk.getContract("{{contract_address}}");

// call any function in your contract
await contract.call("myCustomFunction", param1, param2);

// if your contract follows the ERC721 standard, contract.nft will be present
const allNFTs = await contract.nft.query.all();

// if your contract extends IMintableERC721, contract.nft.mint will be present
const tx = await contract.nft.mint.to("0x...", {
name: "Cool NFT",
image: readFileSync("some_image.png"),
});

Constructors

ConstructorModifiersDescription
(constructor)(network, address, abi, storage, options, contractWrapper)(BETA) Constructs a new instance of the SmartContract class

Properties

PropertyModifiersTypeDescription
contractTypestatic"custom"(BETA)
editionErc1155 | undefined(BETA) Auto-detects ERC1155 standard functions.
estimatorGasCostEstimator<TContract>(BETA)
eventsContractEvents<TContract>(BETA)
interceptorContractInterceptor<TContract>(BETA)
metadataContractMetadata<BaseContract, any>(BETA)
nftErc721 | undefined(BETA) Auto-detects ERC721 standard functions.
platformFeesContractPlatformFee<IPlatformFee> | undefined(BETA)
publishedMetadataContractPublishedMetadata<TContract>(BETA)
rolesContractRoles<IPermissionsEnumerable, any> | undefined(BETA)
royaltiesContractRoyalty<IRoyalty, any> | undefined(BETA)
salesContractPrimarySale<IPrimarySale> | undefined(BETA)
tokenErc20 | undefined(BETA) Auto-detects ERC20 standard functions.

Methods

MethodModifiersDescription
call(functionName, args)(BETA) Call any function on this contract
getAddress()(BETA)
onNetworkUpdated(network)(BETA)

Signature:

export declare class SmartContract<TContract extends BaseContract = BaseContract> implements UpdateableNetwork

Implements: UpdateableNetwork