JavaScript SDK

The Tatum SDK (@tatumio/tatum) is a JavaScript and TypeScript library for RPC calls, wallet balances and transactions, NFTs and address monitoring.

The Tatum SDK is designed to simplify blockchain application development. Whether you're monitoring blockchain addresses, making RPC calls, managing NFTs, or querying wallet balances and transactions, Tatum SDK streamlines the process with its robust features.

Engineered with a developer-first approach, Tatum SDK accelerates your blockchain application development, regardless of your experience level.

Prerequisites

Before diving into TatumSDK, ensure that you have the following prerequisites installed:

  • Node.js: Ensure you have the latest LTS version installed.
  • npm: npm is bundled with Node.js, so installing Node.js should automatically install npm.

Installation of Tatum SDK

To install SDK, simply run the following command in your terminal or command prompt.
This will install the Tatum SDK package and its dependencies:

npm install @tatumio/tatum
yarn add @tatumio/tatum
pnpm install @tatumio/tatum
bun install @tatumio/tatum

Examples:

Fetch the native balance of wallet

Now that you have installed the Tatum SDK, make your first call: fetch the native balance of a wallet. Replace {YOUR_API_KEY} with your API key from the Tatum Dashboard (no key yet? see Getting Started with the Tatum API) and {ADDRESS} with an Ethereum address. Here's the code snippet:

import { TatumSDK, Network } from '@tatumio/tatum'

const tatum = await TatumSDK.init({ network: Network.ETHEREUM, apiKey: '{YOUR_API_KEY}' });
const balance = await tatum.address.getBalance({
    addresses: ['{ADDRESS}'],
});

console.log(balance.data.find((item) => item.type === 'native'));

// Stop the SDK's background jobs so the script can exit
await tatum.destroy();

Try the first call in the Codepen below:

RPC call to get latest block

import { TatumSDK, Ethereum, Network } from '@tatumio/tatum'

// Init chain of your choice
const tatum = await TatumSDK.init<Ethereum>({network: Network.ETHEREUM})
 
// Use our interfaces to make the call
const { result: latestBlock } = await tatum.rpc.blockNumber()
 
console.log(`Latest block is ${latestBlock}`)

await tatum.destroy()

Related guides


Did this page help you?