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
Constructor | Modifiers | Description |
---|---|---|
(constructor)(network, address, abi, storage, options, contractWrapper) | (BETA) Constructs a new instance of the SmartContract class |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
contractType | static | "custom" | (BETA) |
edition | Erc1155 | undefined | (BETA) Auto-detects ERC1155 standard functions. | |
estimator | GasCostEstimator<TContract> | (BETA) | |
events | ContractEvents<TContract> | (BETA) | |
interceptor | ContractInterceptor<TContract> | (BETA) | |
metadata | ContractMetadata<BaseContract, any> | (BETA) | |
nft | Erc721 | undefined | (BETA) Auto-detects ERC721 standard functions. | |
platformFees | ContractPlatformFee<IPlatformFee> | undefined | (BETA) | |
publishedMetadata | ContractPublishedMetadata<TContract> | (BETA) | |
roles | ContractRoles<IPermissionsEnumerable, any> | undefined | (BETA) | |
royalties | ContractRoyalty<IRoyalty, any> | undefined | (BETA) | |
sales | ContractPrimarySale<IPrimarySale> | undefined | (BETA) | |
token | Erc20 | undefined | (BETA) Auto-detects ERC20 standard functions. |
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