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
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(network, address, abi, storage, options, chainId, contractWrapper) | (BETA) Constructs a new instance of the SmartContract class |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| abi | ContractInterface | (BETA) | |
| appURI | ContractAppURI<BaseContract> | (BETA) | |
| chainId | readonly | number | (BETA) |
| encoder | ContractEncoder<TContract> | (BETA) | |
| erc1155 | readonly | Erc1155 | (BETA) Auto-detects ERC1155 standard functions. |
| erc20 | readonly | Erc20 | (BETA) Auto-detects ERC20 standard functions. |
| erc721 | readonly | Erc721 | (BETA) Auto-detects ERC721 standard functions. |
| estimator | GasCostEstimator<TContract> | (BETA) | |
| events | ContractEvents<TContract> | (BETA) | |
| interceptor | ContractInterceptor<TContract> | (BETA) | |
| metadata | ContractMetadata<BaseContract, any> | (BETA) | |
| owner | readonly | ContractOwner<Ownable> | (BETA) Set and get the owner of the contract |
| platformFees | readonly | ContractPlatformFee<IPlatformFee> | (BETA) Handle platform fees |
| publishedMetadata | ContractPublishedMetadata<TContract> | (BETA) | |
| roles | readonly | ContractRoles<IPermissions, any> | (BETA) Handle permissions |
| royalties | readonly | ContractRoyalty<IRoyalty, any> | (BETA) Handle royalties |
| sales | readonly | ContractPrimarySale<IPrimarySale> | (BETA) Handle primary sales |
Methods
| Method | Modifiers | Description |
|---|---|---|
| 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