Docs

TypeScript SDK

A type-safe library to interact with any EVM-compatible blockchain in both Node.js and the browser.

Connect to user's wallets, interact with smart contracts, sign messages, and utilize common standards such as tokens, NFTs, marketplaces; all with built-in RPC URLs, IPFS gateways, and more.

TypeScript SDK

TypeScript SDK is open-source. View and contribute to its source code on GitHub.

Installation

npx thirdweb install

Get Started

Check out the getting started guide to learn how to use the SDK in less than 2 minutes.

Get started with the TypeScript SDK

How It Works

The TypeScript SDK provides a type-safe interface to interact with your smart contracts, wallets, and the blockchain.

It can interact with any contract on any EVM-compatible blockchain, without having to specify ABIs, RPC URLs, or IPFS gateways.

It also simplifies interacting with standard contracts using the Extensions Framework. Standards and common contract patterns are detected by the SDK and unlocks a convenient, high level API which does the heavy lifting for you.

For example, if your smart contract implements the standard ERC721 interface, you can list all NFTs in the contract in one line with contract.erc721.getAll() method. This will handle querying supply, downloading metadata and owners for each token, and returning a list of type safe NFT objects.

import { ThirdwebSDK } from "@thirdweb-dev/sdk";
// instantiate the SDK with a simple chain name or chain id
const sdk = new ThirdwebSDK("polygon");
// access your deployed contracts, ABI is optional
const contract = await sdk.getContract("0x...");
// Read data using direct calls to your contract
const myData = await contract.call("myFunction");
// Or Using the extensions API matching to your contract extensions
// ex: read all ERC721 NFTs, along with metadata and owners
const allNFTs = await contract.erc721.getAll();
// upload metadata to IPFS and mint a new NFT
await contract.erc721.mint({
name: "Cool NFT",
description: "Minted NFT from code!",
image: fs.readFileSync("path/to/image.png"), // This can be an image url or file
});

This saves a lot of time and effort, as you don't have to manually implement these common functions yourself.

To get started, create an instance of the ThirdwebSDK class to connect to your smart contract and start interacting with it's functions and extensions.