thirdweb SDK

thirdweb SDK is a library that enables developers to build web3 applications and interact with any EVM-compatible blockchain.

You can use the thirdweb SDK to build apps and interact with smart contracts deployed on the Pivotal network.

The thirdweb SDK is available in various programming languages, including: Reactarrow-up-right, React Nativearrow-up-right, TypeScriptarrow-up-right, Pythonarrow-up-right, Goarrow-up-right, and Unityarrow-up-right.

Visit the thirdweb documentationarrow-up-right for more instructions on using the thirdweb SDKs.


To install the thirdweb SDK, run:

npm install @thirdweb-dev/sdk ethers@5

Initializing the SDK with Pivotalarrow-up-right

To get started using the SDK, you must first initialize an instance of ThirdWebSDK, and connect to the Pivotal network by passing in the Pivotal chain.

To initialize the SDK with the Pivotal network and get a contract:

import { Pivotal } from '@thirdweb-dev/chains';
import { ThirdwebSDK } from '@thirdweb-dev/sdk/evm';

const sdk = new ThirdwebSDK(Pivotal);
const contract = await sdk.getContract('0x0000000000000000000000000000000000000000');
circle-info

The code snippet above uses the React SDKarrow-up-right. The thirdweb SDKs are also available in React Nativearrow-up-right, TypeScriptarrow-up-right, Pythonarrow-up-right, Goarrow-up-right, and Unityarrow-up-right.

If alternatively you'd like to initialize the SDK with Pivotal Sepolia (testnet), use the following code instead:


Interacting with smart contractsarrow-up-right

Once you initialize the SDK and connect to a smart contract deployed to Pivotal, you can start calling functions on it using the SDK.

circle-info

Any interaction you make with a smart contract will be made from the connected wallet automatically.

Using contract extension functionsarrow-up-right

The thirdweb SDK provides convenience functions when your smart contract uses extensionsarrow-up-right. This is the easiest way to read data and write transactions with your smart contracts.

For example, if your contract implements the ERC721arrow-up-right extension, you can utilize all of the functions of the corresponding erc721 standardarrow-up-right in the SDK.

As an example, below is a code snippet that uses useOwnedNFTsarrow-up-right hook to get a list of NFTs owned by a single wallet address:

Usagearrow-up-right

For more examples on using contract extension functions, visit the thirdweb developer documentationarrow-up-right.

Reading contract dataarrow-up-right

If your contract doesn’t use any extensionsarrow-up-right, or you want to directly call functions on your smart contract to read data, you can use the useContractReadarrow-up-right hook.

Read data on your contract from a connected wallet:

Writing transactionsarrow-up-right

If your contract doesn’t use any extensionsarrow-up-right, or you want to directly call functions on your smart contract to write data, you can use the useContractWritearrow-up-right hook.

Make transactions on your contract from a connected wallet:

Last updated