Interacting with Contracts
The TypeScript SDK provides different ways for you to interact with smart contract functionality:
- Generic reading data from and writing transactions to smart contracts using the
call
method. - Using special features that are available for each extension that your smart contract implements.
Extensions
Each extension (i.e. Solidity interface) that your smart contract implements unlocks new functionality for you to use in the SDK. For example, NFT collection smart contracts implements the ERC721 extension, allowing you can to use the ERC721 extension in the SDK when interacting with that contract.
These extension interfaces are available for the most common EIP standards, including support for ERC20, ERC721, ERC1155, permissions, metadata, and more. They handle the pre-processing of calling the smart contract functions for you, such as checking for token approval, uploading metadata to IPFS, formatting inputs, etc. Making your code safer and easier to write.
contract MyContract is
ERC721,
IERC721Mintable {
// ...
}
const MyApp = () => {
// ERC721 -> ".erc721"
// IERC721Mintable -> ".mint"
const tx = await contract.erc721.mint({...})
}
Example: the "mint" function above uploads and pins your NFT metadata to IPFS for you before minting.
Supported Extensions
ERC721
Name | Description | Documentation |
---|---|---|
ERC721 | Basic functionality of ERC721 "non-fungible" NFTs | ERC721 |
ERC721BatchMintable | Batch minting of new NFTs | ERC721BatchMintable |
ERC721Burnable | Burn (take out of circulation) NFTs | ERC721Burnable |
ERC721ClaimConditions | Allow users to claim NFTs from your drop under specific conditions | ERC721ClaimConditions |
ERC721LazyMintable | Batch lazy-mint new NFTs for others to claim them | ERC721LazyMintable |
ERC721Enumerable | Enumerate through NFTs in a contract to get all or get owned NFTs | ERC721Enumerable |
ERC721Mintable | Mint new NFTs into the contract | ERC721Mintable |
ERC721Revealable | Use delayed reveal on NFTs you lazy mint | ERC721Revealable |
ERC721Supply | View information about the supply of the NFT collection | ERC721Supply |
ERC721TieredDrop | Use special tiered drop functionality | ERC721TieredDrop |
ERC721SignatureMint | Use signature-based minting functionality to mint new NFTs into the contract | ERC721SignatureMint |
ERC1155
Name | Description | Documentation |
---|---|---|
ERC1155 | Basic functionality of ERC1155 "semi-fungible" NFTs | ERC1155 |
ERC1155BatchMintable | Batch minting of new NFTs | ERC1155BatchMintable |
ERC1155Burnable | Burn (take out of circulation) NFTs | ERC1155Burnable |
ERC1155ClaimConditions | Allow users to claim NFTs from your drop under specific conditions | ERC1155ClaimConditions |
ERC1155Enumerable | Enumerate through NFTs in a contract to get all or get owned NFTs | ERC1155Enumerable |
ERC1155LazyMintable | Batch lazy-mint new NFTs for others to claim them | ERC1155LazyMintable |
ERC1155Mintable | Mint new NFTs into the contract | ERC1155Mintable |
ERC1155Revealable | Use delayed reveal on NFTs you lazy mint | ERC1155Revealable |
ERC1155SignatureMintable | Use signature-based minting functionality to mint new NFTs into the contract | ERC1155SignatureMintable |
ERC20
Name | Description | Documentation |
---|---|---|
ERC20 | Basic functionality of ERC20 "fungible" tokens | ERC20 |
ERC20BatchMintable | Batch minting of new tokens | ERC20BatchMintable |
ERC20Burnable | Burn (take out of circulation) tokens | ERC20Burnable |
ERC20Mintable | Mint new tokens into the contract | ERC20Mintable |
ERC20SignatureMintable | Use signature-based minting functionality to mint new tokens into the contract | ERC20SignatureMintable |
ERC20ClaimConditions | Allow users to claim tokens from your drop under specific conditions | ERC20ClaimConditions |
Marketplace V3
Name | Description | Documentation |
---|---|---|
DirectListings | List NFTs for sale, allowing other users to make offers or buy them outright | DirectListings |
EnglishAuctions | List NFTs for auction, allowing users to bid on them | EnglishAuctions |
Offers | Allow users to make offers on any NFT on a smart contract, even if not listed for sale | Offers |
General Extensions
Name | Description | Documentation |
---|---|---|
ContractMetadata | Get and set metadata about a smart contract | ContractMetadata |
Ownable | Get and set the owner wallet address of a smart contract | Ownable |
Gasless | Enable gasless transactions for functions on a smart contract | Gasless |
Permissions | Restrict function execution for users who hold specific roles | Permissions |
PackVRF | Special functionality for using the PackVRF contract | PackVRF |
PlatformFee | Charge a percentage fee wherever there is a transfer of currency in your contract | PlatformFee |
PluginRouter | Special functionality for using dynamic contracts | PluginRouter |
PrimarySale | Configure where/how much funds are sent for sales of tokens in your contract | PrimarySale |
Royalty | Configure where/how much funds are sent for secondary sales of tokens in your contract | Royalty |