Extensions Framework
In addition to generic read/write contract functions, the SDK by automatically detecting common patterns on your contract, known as Solidity Extensions, and provides a catalog of high level APIs that simplify the interaction with your contract.
A typical Example
Let's say you have a contract that implements a ERC721 standard. The SDK will automatically detect this pattern and provide a set of APIs that will allow you to interact with your contract in a more convenient way.
Because the contract implements the ERC721 standard, a set of APIs become available under the erc721 namespace.
- The
erc721.getAll()anderc721.getOwned()functions will handle querying the supply, fetching the metadata and owner for each NFT and return a convenient, typedNFTarray. - The
erc721.mint()will handle uploading the metadata to IPFS, and minting a new NFT with the given metadata to the connected wallet address.
This saves a lot of time and effort, as you don't have to manually implement these common functions yourself.
Detecting avilable extensions
You can check which extensions are available on a contract by calling the getAllDetectedExtensionNames() function.
Preparing transactions
Just like with contract.prepare(), you can prepare a transaction for a specific extension by calling contract.{{extension}}.{{functionName}}.prepare(args). This will return a Transaction object that you can use to encode, estimate, simulate, sign or send the transaction.
One common use case for example is to prepare and encoded 2 different transactions, then execute them atomically using multicall:
All Available Extensions
All extensions are available under their own namespace in the SmartContract class, and map to a corresponding Solidity Extension