Getting Started
In this quickstart guide, we'll create a basic script to generate a wallet using a private key and send a transaction. We’ll assume you already have a TypeScript project created.
To get started, install the thirdweb SDK using your preferred package manager.
Get an API key from https://thirdweb.com/dashboard/settings/api-keys and add it to your
.env
.Create a thirdweb client in your script.
A client is all your need to start reading blockchain data.
- Import the extensions you want to use.
- Define a contract with
getContract
at a given address and chain. - Call the extension function to read the data.
To perform transactions from your script, you'll need an account. You can generate a wallet from a private key using the
privateKeyToAccount
function.Let's read balance of the account you just created, you'll need funds to perform transactions.
With the account created and funded, you can now send a transaction.
- Import the extension you want to use.
- Define a contract with
getContract
at a given address and chain. - Call the extension function to prepare the transaction.
- Send the transaction.
You can also call generic contract functions using the
prepareContractCall
function by just specifying the solidity method signature you want to call. The arguments will be automatically inferred based on the method signature.You've now learned the basics of how to use the thirdweb SDK to read and write to the blockchain. You can now start building your own applications and explore the full potential of the SDK.