npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tatumcom/js

v1.5.11

Published

Tatum JS SDK

Downloads

916

Readme

GitHub license npm version GitHub license Build

Welcome

Tatum SDK is a powerful, feature-rich TypeScript/JavaScript library that streamlines the development of blockchain applications. Designed for developers looking to integrate various blockchain functionalities into their projects, Tatum SDK simplifies the process by providing a user-friendly and consistent interface to interact with a wide range of blockchains like Ethereum, Polygon, Bitcoin, and many more.

With Tatum SDK, you can:

Perform native RPC calls

Easily interact with different blockchains through native RPC calls, abstracting away the complexities of managing separate RPC clients for each blockchain.

Create notifications

Monitor wallet activity with ease by setting up real-time notifications for events such as incoming and outgoing transactions, balance updates, and contract interactions.

Access wallet information

Retrieve vital wallet details, including balances, transaction history, and other relevant information, all through a single interface.

Tatum SDK is constantly evolving, with new features and support for additional blockchains being added regularly. This comprehensive library is the ideal choice for developers who are keen on building robust, scalable, and efficient blockchain applications without getting bogged down by the intricacies of working with multiple blockchain protocols.

This guide will walk you through the basic setup, installation, and usage of TatumSDK to help you harness the full potential of this library.

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

To install TatumSDK, simply run the following command in your terminal or command prompt:

Install using npm

npm install @tatumcom/js

Install using yarn

yarn add @tatumcom/js

Install using pnpm

pnpm install @tatumcom/js

Getting started

Basic Usage

Here's a brief overview of how to utilize TatumSDK for RPC calls and subscribing to notifications.

Initialization

Start by importing the TatumSDK library and initializing Ethereum client as follows:

import { TatumSDK, Network, Ethereum } from '@tatumcom/js'

const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM })

RPC Calls

To make RPC calls, use the available methods to interact with Ethereum blockchain. For example, to fetch the balance of a specific Ethereum address:

import { TatumSDK, Network, Ethereum } from '@tatumcom/js'

const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM })

const { result } = await tatum.rpc.getBalance('0x742d35Cc6634C0532925a3b844Bc454e4438f44e')
console.log(`Balance: ${data}`)

Subscribing to Notifications

To subscribe to notifications for events related to a specified Ethereum address, choose a type of event you want to be notified about. We are going to use addressEvent as an example, which sends you notification about any transfer on the address - native ones, ERC20 tokens or NFTs. To subscribe to this event, use the following code:

import { TatumSDK, Network, Ethereum } from '@tatumcom/js'

const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM })

const response = await tatum.notification.subscribe.addressEvent({
  url: 'https://<YOUR_WEBHOOK_URL>',
  address: '0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990',
})

console.log(response)
// 🎉  Now your address is subscribed for any events!

Get NFT balance of a wallet

Using TatumSDK, obtain the NFT balance of an address by calling the getNFTBalance method within the NFT submodule and passing the target address as an argument. This streamlined process efficiently retrieves the total number of NFTs owned by the specified address. To achieve this, use the following code:

import { TatumSDK, Network, Ethereum, NftAddressBalance } from '@tatumcom/js'

const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM })

const balances: NftAddressBalance[] = await tatum.nft.getBalance({
  addresses: ['0x53e8577c4347c365e4e0da5b57a589cb6f2ab849'],
})

console.log(balances)

Connect to MetaMask and send transaction

Using TatumSDK, it's possible to connect your browser application to MetaMask and perform transactions using it. To achieve this, use the following code:

import { TatumSDK, Network, Ethereum } from '@tatumcom/js'

const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM })

const account: string = await tatum.walletProvider.metaMask.connect()
const txId: string = await tatum.walletProvider.metaMask.transferNative(
  '0x53e8577C4347C365E4e0DA5B57A589cB6f2AB848',
  '1',
)

console.log(txId)

Get exchange rates

Using TatumSDK, obtain current fiat/crypto exchange rates To achieve this, use the following code:

import { TatumSDK, Network, Ethereum } from '@tatumcom/js'

const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM })

const res = await tatum.rates.getCurrentRate('BTC', 'EUR')

console.log(res.data)

Get current fees

Using TatumSDK, you can obtain recommended fee/gas price for a blockchain. Supported blockchains are:

  • Bitcoin
  • Litecoin
  • Dogecoin
  • Ethereum
import { TatumSDK, Network, Ethereum } from '@tatumcom/js'

const tatum = await TatumSDK.init<Ethereum>({
  network: Network.ETHEREUM_SEPOLIA,
  verbose: true,
  retryDelay: 1000,
  retryCount: 2,
  version: ApiVersion.V1,
})

const result = await tatum.fee.getCurrentFee()

console.log(result.data)

Get token balance

Using TatumSDK, obtain all fungible token balances of an address by calling the getBalance method within the token submodule and passing the target address as an argument. This streamlined process efficiently retrieves all balances for fungible tokens that specified address holds. To achieve this, use the following code:

import { TatumSDK, Network, Ethereum } from '@tatumcom/js'

const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM_SEPOLIA })

const { data: balances } = await tatum.token.getBalance({
  addresses: ['0x2cbaf358c0af93096bd820ce57c26f0b7c6ec7ab'],
})

console.log(balances)

Documentation

Examples

Legacy versions

Older versions of the Tatum SDK has been moved to long living branches Tatum SDK V1 and Tatum SDK V2.

Contributing

Contributions to the Tatum SDK are welcome. Please ensure that you have tested your changes with a local client and have added unit test coverage for your code.

Bugs and feature requests

Have a bug or a feature request? Please first read the issue guidelines and search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.