Skip to content

Latest commit

 

History

History
404 lines (271 loc) · 17.7 KB

README.md

File metadata and controls

404 lines (271 loc) · 17.7 KB

Logo

Tatum SDK

Welcome to Tatum SDK - TypeScript/JavaScript Library for Simplifying Blockchain Development.
Documentation

Report bug

GitHub license npm version GitHub license Build


🚀 Tatum SDK

A powerful, feature-rich TypeScript/JavaScript library that streamlines the development of blockchain applications.

🔍 Designed For Developers If you're looking to integrate blockchain functionalities into your projects, Tatum SDK is for you.

We simplify the integration process by offering:

  • A user-friendly interface 🤝
  • Consistent interaction with a broad range of blockchains, including Ethereum 🔷, Polygon 🟣, Bitcoin ₿, and many more.

For more details, visit our documentation and examples.

With Tatum SDK, you can:

🔌 Perform Native RPC Calls

Interact seamlessly with various blockchains through native RPC calls. Say goodbye to the hassle of juggling separate RPC clients for each blockchain.

Documentation
EVM Blockchains
Ethereum RPC documentation
Polygon RPC documentation
Flare RPC documentation
Haqq RPC documentation
Optimism RPC documentation
UTXO Blockchains
Bitcoin RPC documentation
Litecoin RPC documentation
Dogecoin RPC documentation
Solana Blockchains
Solana RPC documentation
XPR Blockchains
XPR RPC documentation
Tron Blockchains
Tron RPC documentation

🔔 Create Notifications

Effortlessly monitor wallet activities. Set up real-time notifications for events like:

Documentation
Start monitoring of the address
Stop monitoring of the address
Get all sent notifications
Get all existing monitoring subscriptions

👛 Access Wallet Information

Through a single interface, obtain crucial wallet details such as balances, transaction history, and other pertinent information.

Documentation
Get all assets the wallet holds
Get all transactions on the wallet

🖼️ NFT Actions

Dive into a comprehensive suite of actions related to non-fungible tokens (NFTs).

Documentation
Get all NFTs the wallet holds
Get all NFTs in the NFT collection
Trace the history of a specific NFT
Show the NFT history of a wallet
Create NFT Collection
Create MultiToken NFT Collection
Retrieve the owner of the NFT
Check if the wallet owns a specific NFT
Get the metadata of a specific NFT

🪙 Fungible Tokens

Explore the world of fungible tokens, manage their properties, and track your assets seamlessly.

Documentation
Get all fungible tokens the wallet holds
Show fungible token history of a wallet
Get metadata of a fungible token
Create a fungible token

⛽ Fee Estimation

Stay updated with real-time fee insights and ensure smooth transactions without overpaying.

Documentation
Fetch real-time fee data

💻 Wallet Provider

Integrate, transact, and manage assets using a secure and user-friendly wallet provider interface.

Documentation
Connect a wallet
Transfer native assets
Transfer your NFT
Create your NFT Collection
Create your Fungible Token
Create your NFT (ERC-1155 MultiToken) Collection
Transfer fungible tokens like USDT
Approve the transfer of a fungible token like USDT
Build your own custom transaction

💲 Exchange Rates

Access the latest crypto exchange rates and supported currency information to stay ahead in the market.

Documentation
Get current exchange rate of the crypto asset
Get current rates for multiple crypto assets at once
Supported Crypto Currencies
Supported Fiats

📘 Getting Started with TatumSDK

This guide will lead you step by step, from basic setup and installation to harnessing the immense capabilities of our library. For a detailed walkthrough, check out the Getting Started page.

📊 TatumSDK Dashboard

Experience powerful insights into your application's usage with the Tatum Dashboard. It provides real-time analytics, user engagement metrics, and an intuitive interface, seamlessly integrating with TatumSDK for optimal app monitoring.

🌱 Always Evolving

Our library is on a continuous journey of growth. We regularly add new features and extend support for more blockchains. It's the go-to choice for developers aiming to craft robust, scalable, and efficient blockchain apps without the overwhelming intricacies of diverse blockchain protocols.

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 @tatumio/tatum

Install using yarn

yarn add @tatumio/tatum

Install using pnpm

pnpm install @tatumio/tatum

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 '@tatumio/tatum'

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

// Destroy Tatum SDK - needed for stopping background jobs
tatum.destroy()

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 '@tatumio/tatum'

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

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

// Destroy Tatum SDK - needed for stopping background jobs
tatum.destroy()

For more details, check out the RPC documentation.

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 '@tatumio/tatum'

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!

// Destroy Tatum SDK - needed for stopping background jobs
tatum.destroy()

For more details, check out the Notifications documentation.

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 '@tatumio/tatum'

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

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

console.log(balances)

// Destroy Tatum SDK - needed for stopping background jobs
tatum.destroy()

For more details, check out the NFTs documentation.

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 '@tatumio/tatum'

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)

// Destroy Tatum SDK - needed for stopping background jobs
tatum.destroy()

For more details, check out the Wallet Provider documentation.

Get exchange rates

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

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

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

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

console.log(res.data)

// Destroy Tatum SDK - needed for stopping background jobs
tatum.destroy()

For more details, check out the Exchange Rates documentation.

Get current fees

Using TatumSDK, you can obtain recommended fee/gas price for a blockchain.

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

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)

// Destroy Tatum SDK - needed for stopping background jobs
tatum.destroy()

For more details, check out the Fee Estimation documentation.

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 '@tatumio/tatum'

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

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

console.log(balances)

// Destroy Tatum SDK - needed for stopping background jobs
tatum.destroy()

For more details, check out the Fungible Tokens documentation.

Get all transactions on the wallet

Using TatumSDK, you can obtain transaction history of the wallet.

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

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

const { data: txs } = await tatum.address.getTransactions({
  address: '0x514d547c8ac8ccbec29b5144810454bd7d3625ca',
});

console.log(txs);

// Destroy Tatum SDK - needed for stopping background jobs
tatum.destroy()

For more details, check out the Wallet address operations documentation.

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.

Changes will be included with the nearest release (but please point out if you deem changes worthy dedicated release).

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.