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.erc721.query.all();

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

Constructors

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

Properties

PropertyModifiersTypeDescription
abiContractInterface(BETA)
appURIContractAppURI<BaseContract>(BETA)
chainIdreadonlynumber(BETA)
encoderContractEncoder<TContract>(BETA)
erc1155readonlyErc1155(BETA) Auto-detects ERC1155 standard functions.
erc20readonlyErc20(BETA) Auto-detects ERC20 standard functions.
erc721readonlyErc721(BETA) Auto-detects ERC721 standard functions.
estimatorGasCostEstimator<TContract>(BETA)
eventsContractEvents<TContract>(BETA)
interceptorContractInterceptor<TContract>(BETA)
metadataContractMetadata<BaseContract, any>(BETA)
ownerreadonlyContractOwner<Ownable>(BETA) Set and get the owner of the contract
platformFeesreadonlyContractPlatformFee<IPlatformFee>(BETA) Handle platform fees
publishedMetadataContractPublishedMetadata<TContract>(BETA)
rolesreadonlyContractRoles<IPermissions, any>(BETA) Handle permissions
royaltiesreadonlyContractRoyalty<IRoyalty, any>(BETA) Handle royalties
salesreadonlyContractPrimarySale<IPrimarySale>(BETA) Handle primary sales

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