Home
Softono
t

tatumio

Professional software vendor delivering innovative solutions on the Softono platform. Specialized in both open-source and proprietary software development.

Total Products
2

Software by tatumio

tatum-js
Open Source

tatum-js

[![Tatum Website](https://assets-global.website-files.com/62624e283b503f3e68275638/62624e283b503fde012757c1_Light.svg)](https://tatum.io) # 🚀 Tatum SDK – Your Gateway to Blockchain The Tatum SDK is a comprehensive TypeScript/JavaScript library 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: - 🕵️‍♂️ **Blockchain Monitoring**: Easily track activities on any blockchain address. - 📞 **RPC Calls Simplified**: Interact with various blockchains through simplified RPC calls. - 🖼️ **NFT Insights**: Access detailed information on NFT balances, transactions, and ownership. - 💰 **Wallet Intelligence**: Get precise data on wallet balances and transaction history. [![GitHub Downloads](https://img.shields.io/npm/dm/@tatumio/tatum)](https://github.com/tatumio/tatum-js) [![NPM Version](https://img.shields.io/npm/v/@tatumio/tatum.svg?style=flat-square)](https://www.npmjs.com/package/@tatumio/tatum) [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/tatumio/tatum-js/blob/master/LICENSE.txt) [![Build](https://img.shields.io/github/actions/workflow/status/tatumio/tatum-js/build.yml?branch=master)](https://img.shields.io/github/actions/workflow/status/tatumio/tatum-js/build.yml?branch=master) --- 🔑 **Don't have an API key?** Unlock all networks, features, and monitor error logs & usage with ease. [Create API Key for FREE](https://dashboard.tatum.io) - Start building on Tatum with full access to our powerful suite of features. ## Tailored for Developers Engineered with a developer-first approach, Tatum SDK accelerates your blockchain application development, regardless of your experience level. Explore our [Documentation](https://docs.tatum.io) and [Getting Started Guide](https://github.com/tatumio/tatum-js#getting-started) to jumpstart your projects: - **Super fast development:** Start building blockchain applications in no time. - **No previous blockchain experience required:** Perfect for beginners and experts alike. - **One line of code:** Perform complex tasks with minimal effort. Need help or want to contribute? [Report Bugs](https://github.com/tatumio/tatum-js/issues/new?assignees=-&labels=bug&template=bug_report.yml), join our community, or collaborate on improvements. [![Join us on Discord](https://img.shields.io/discord/847940290903932939?style=social&logo=discord&label=Discord)](https://discord.gg/tatum) [![Follow on X (formerly Twitter)](https://img.shields.io/twitter/follow/tatum_io?style=social&logo=x)](https://twitter.com/tatum_io) [![Subscribe on YouTube](https://img.shields.io/youtube/channel/views/UCF-OAfXNJ9h3U2ycHE1NGNw?style=social&logo=youtube&label=Youtube)](https://www.youtube.com/channel/UCF-OAfXNJ9h3U2ycHE1NGNw) ### 🔌 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](https://docs.tatum.io/docs/rpc/evm-blockchains/ethereum-rpc-documentation) | | [Polygon RPC](https://docs.tatum.io/docs/rpc/evm-blockchains/polygon-rpc-documentation) | | [Flare RPC](https://docs.tatum.io/docs/rpc/evm-blockchains/flare-rpc-documentation) | | [Haqq RPC](https://docs.tatum.io/docs/rpc/evm-blockchains/haqq-rpc-documentation) | | [Optimism RPC](https://docs.tatum.io/docs/rpc/evm-blockchains/optimism-rpc-documentation) | | [Horizen EON RPC](https://docs.tatum.io/docs/rpc/evm-blockchains/horizen-eon-rpc-documentation) | | [Arbitrum One RPC](https://docs.tatum.io/docs/rpc/evm-blockchains/arbitrum-rpc-documentation) | | [Chiliz RPC](https://docs.tatum.io/docs/rpc/evm-blockchains/chiliz-rpc-documentation) | | [Ethereum Classic RPC](https://docs.tatum.io/docs/rpc/evm-blockchains/ethereum-classic-rpc-documentation) | | [Klaytn RPC](https://docs.tatum.io/docs/rpc/evm-blockchains/klaytn-rpc-documentation) | | [Avalanche RPC](https://docs.tatum.io/docs/rpc/evm-blockchains/avalanche-rpc-documentation) | | [Celo RPC](https://docs.tatum.io/docs/rpc/evm-blockchains/celo-rpc-documentation) | | [XinFin RPC](https://docs.tatum.io/docs/rpc/evm-blockchains/xinfin-rpc-documentation) | | [Fantom RPC](https://docs.tatum.io/docs/rpc/evm-blockchains/fantom-rpc-documentation) | | [Base RPC](https://docs.tatum.io/docs/rpc/evm-blockchains/base-rpc-documentation) | | **UTXO Blockchains** | | [Bitcoin RPC](https://docs.tatum.io/docs/rpc/utxo-blockchains/bitcoin-rpc-documentation) | | [Litecoin RPC](https://docs.tatum.io/docs/rpc/utxo-blockchains/litecoin-rpc-documentation) | | [Dogecoin RPC](https://docs.tatum.io/docs/rpc/utxo-blockchains/dogecoin-rpc-documentation) | | [ZCash RPC](https://docs.tatum.io/docs/rpc/utxo-blockchains/zcash-rpc-documentation) | | [Bitcoin Cash RPC](https://docs.tatum.io/docs/rpc/utxo-blockchains/bitcion-cash-rpc-documentation) | | **Other Blockchains** | | [Solana RPC](https://docs.tatum.io/docs/rpc/solana-rpc-documentation) | | [XPR RPC](https://docs.tatum.io/docs/rpc/xrp-rpc-documentation) | | [Tron RPC](https://docs.tatum.io/docs/rpc/tron-rpc-documentation) | | [Eos RPC](https://docs.tatum.io/docs/rpc/eos-rpc-documentation) | | [Tezos RPC](https://docs.tatum.io/docs/rpc/tezos-rpc-documentation) | | [Agorand RPC](https://docs.tatum.io/docs/rpc/algo-rpc-documentation) | | [Cardano RPC](https://docs.tatum.io/docs/rpc/cardano-rpc-documentation) | | [Stellar RPC](https://docs.tatum.io/docs/rpc/stellar-rpc-documentation) | | [Iota RPC](https://docs.tatum.io/docs/rpc/iota-rpc-documentation) | | [Kadena RPC](https://docs.tatum.io/docs/rpc/kadena-rpc-documentation) | | [Rostrum RPC](https://docs.tatum.io/docs/rpc/rostrum-rpc-documentation) | | [Cronos RPC](https://docs.tatum.io/docs/rpc/cronos-rpc-documentation) | ### 🔔 Create Notifications Effortlessly monitor wallet activities. Set up real-time notifications for events like: | Documentation | | ----------------------------------------------------------------------------------------------------------------------------------------------------- | | [Start monitoring of the address](https://docs.tatum.io/docs/notifications/notification-workflow/start-monitoring-of-the-address) | | [Stop monitoring of the address](https://docs.tatum.io/docs/notifications/notification-workflow/stop-monitoring-of-the-address) | | [Get all sent notifications](https://docs.tatum.io/docs/notifications/notification-workflow/get-all-sent-notifications) | | [Get all existing monitoring subscriptions](https://docs.tatum.io/docs/notifications/notification-workflow/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](https://docs.tatum.io/docs/wallet-address-operations/get-all-assets-the-wallet-holds) | | [Get all transactions on the wallet](https://docs.tatum.io/docs/wallet-address-operations/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](https://docs.tatum.io/docs/nfts/get-all-nfts-the-wallet-holds) | | [Get all NFTs in the NFT collection](https://docs.tatum.io/docs/nfts/get-all-nfts-in-the-nft-collection) | | [Trace the history of a specific NFT](https://docs.tatum.io/docs/nfts/trace-the-history-of-a-specific-nft) | | [Show the NFT history of a wallet](https://docs.tatum.io/docs/nfts/show-the-nft-history-of-a-wallet) | | [Create NFT Collection](https://docs.tatum.io/docs/nfts/create-nft-collection) | | [Create MultiToken NFT Collection](https://docs.tatum.io/docs/nfts/create-multitoken-nft-collection) | | [Retrieve the owner of the NFT](https://docs.tatum.io/docs/nfts/retrieve-the-owner-of-the-nft) | | [Check if the wallet owns a specific NFT](https://docs.tatum.io/docs/nfts/check-if-the-wallet-owns-a-specific-nft) | | [Get the metadata of a specific NFT](https://docs.tatum.io/docs/nfts/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](https://docs.tatum.io/docs/fungible-tokens/get-all-fungible-tokens-the-wallet-holds) | | [Show fungible token history of a wallet](https://docs.tatum.io/docs/fungible-tokens/show-fungible-token-history-of-a-wallet) | | [Get metadata of a fungible token](https://docs.tatum.io/docs/fungible-tokens/get-metadata-of-a-fungible-token) | | [Create a fungible token](https://docs.tatum.io/docs/fungible-tokens/create-a-fungible-token) | ### 📁 IPFS Enables you as a developer to use IPFS to store and retrieve your media. | Documentation | | ------------------------------------------------------------------ | | [Upload file to IPFS](https://docs.tatum.io/docs/ipfs/upload-file) | ### ⛽ Fee Estimation Stay updated with real-time fee insights and ensure smooth transactions without overpaying. | Documentation | | ----------------------------------------------------------------------------------- | | [Fetch real-time fee data](https://docs.tatum.io/docs/fee-estimation/getcurrentfee) | ### 💻 Wallet Provider Integrate, transact, and manage assets using a secure and user-friendly wallet provider interface. | Documentation | | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | | [Connect a wallet](https://docs.tatum.io/docs/wallet-provider/metamask/connect-a-wallet) | | [Transfer native assets](https://docs.tatum.io/docs/wallet-provider/metamask/transfer-native-assets) | | [Transfer your NFT](https://docs.tatum.io/docs/wallet-provider/metamask/transfer-your-nft) | | [Create your NFT Collection](https://docs.tatum.io/docs/wallet-provider/metamask/create-your-nft-collection) | | [Create your Fungible Token](https://docs.tatum.io/docs/wallet-provider/metamask/create-your-fungible-token) | | [Create your NFT (ERC-1155 MultiToken) Collection](https://docs.tatum.io/docs/wallet-provider/metamask/create-your-nft-erc-1155-multitoken-collection) | | [Transfer fungible tokens like USDT](https://docs.tatum.io/docs/wallet-provider/metamask/transfer-fungible-tokens-like-usdt) | | [Approve the transfer of a fungible token like USDT](https://docs.tatum.io/docs/wallet-provider/metamask/approve-the-transfer-of-a-fungible-token-like-usdt) | | [Build your own custom transaction](https://docs.tatum.io/docs/wallet-provider/metamask/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](https://docs.tatum.io/docs/exchange-rates/get-current-exchange-rate-of-the-crypto-asset) | | [Get current rates for multiple crypto assets at once](https://docs.tatum.io/docs/exchange-rates/get-current-rates-for-multiple-crypto-assets-at-once) | | [Supported Crypto Currencies](https://docs.tatum.io/docs/exchange-rates/supported-crypto-currencies) | | [Supported Fiats](https://docs.tatum.io/docs/exchange-rates/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](https://docs.tatum.io/sdk/get-started-with-tatum-sdk). ### 📊 TatumSDK Dashboard Experience powerful insights into your application's usage with the [Tatum Dashboard](https://dashboard.tatum.io/). 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](https://www.npmjs.com/) ```console npm install @tatumio/tatum ``` ### Install using [yarn](https://yarnpkg.com/) ```console yarn add @tatumio/tatum ``` ### Install using [pnpm](https://pnpm.io/) ```console 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: ```ts import { TatumSDK, Network, Ethereum } from '@tatumio/tatum' const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM }) // Destroy Tatum SDK - needed for stopping background jobs await tatum.destroy() ``` For more details, check out the [Get started documentation](https://docs.tatum.io/sdk/javascript-typescript-sdk). ### 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: ```ts 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: ${result}`) // Destroy Tatum SDK - needed for stopping background jobs await tatum.destroy() ``` For more details, check out the [RPC documentation](https://docs.tatum.io/docs/rpc). ### 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: ```ts 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 await tatum.destroy() ``` For more details, check out the [Notifications documentation](https://docs.tatum.io/docs/notifications). ### 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: ```ts 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 await tatum.destroy() ``` For more details, check out the [NFTs documentation](https://docs.tatum.io/docs/nfts). ### 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: ```ts import { TatumSDK, Network, Ethereum, MetaMask } from '@tatumio/tatum' const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM }) const account: string = await tatum.walletProvider.use(MetaMask).getWallet() const txId: string = await tatum.walletProvider .use(MetaMask) .transferNative('0x53e8577C4347C365E4e0DA5B57A589cB6f2AB848', '1') console.log(txId) // Destroy Tatum SDK - needed for stopping background jobs await tatum.destroy() ``` For more details, check out the [Wallet Provider documentation](https://docs.tatum.io/docs/wallet-provider). ### Get exchange rates Using TatumSDK, obtain current fiat/crypto exchange rates To achieve this, use the following code: ```ts 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 await tatum.destroy() ``` For more details, check out the [Exchange Rates documentation](https://docs.tatum.io/docs/exchange-rates). ### Get current fees Using TatumSDK, you can obtain recommended fee/gas price for a blockchain. ```ts 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.V3, }) const result = await tatum.fee.getCurrentFee() console.log(result.data) // Destroy Tatum SDK - needed for stopping background jobs await tatum.destroy() ``` For more details, check out the [Fee Estimation documentation](https://docs.tatum.io/docs/fee-estimation). ### 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: ```ts 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 await tatum.destroy() ``` For more details, check out the [Fungible Tokens documentation](https://docs.tatum.io/docs/fungible-tokens). ### Get all transactions on the wallet Using TatumSDK, you can obtain transaction history of the wallet. ```ts 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 await tatum.destroy() ``` For more details, check out the [Wallet address operations documentation](https://docs.tatum.io/docs/wallet-address-operations). ## RPC calls All RPC calls are implemented in the `tatum.rpc.*` submodule. See the [RPC API Reference](https://docs.tatum.io/docs/rpc-api-reference) for more about supported chains and methods. ### Distinguishing Between Archive and Full Nodes When interacting with the blockchain, it's essential to know whether a JSON RPC call requires an archive node or can be serviced by a full node. The distinction hinges on the type of data requested and the historical depth of that data. Here's a breakdown of the conditions under which a call is classified for an archive or a full node: #### Archive Node Calls Archive nodes store the entire history of the blockchain, including the state of all accounts at every block. Calls that require an archive node typically involve querying historical states. Conditions include: 1. **Calls to Methods `getCode` or `call`**: Always require an archive node because they may query the state at any block height. 2. **Calls Including `debug` or `trace` Methods**: These methods require historical data not available on full nodes. 3. **Parameters Indicating a Specific Block Number**: For following methods, if the call specifies a block number, it requires an archive node. This includes: - `getStorageAt` with a specific block number. - `getBalance` with a specific block number. - `getBlockByNumber` when a block number is specified. - `getLogs` calls where `fromBlock` or `toBlock` specify a block number other than the latest. #### Full Node Calls Any other calls not meeting the conditions for archive node calls can be serviced by a full node. These calls typically involve querying the current state of the blockchain. ### Status Pages This section provides a list of various blockchain network status pages, powered by Tatum. These links direct you to real-time status updates for each network. | Status Pages | | ------------------------------------------------------------------------------------------------------------ | | [bitcoin-mainnet.status.tatum.io](https://bitcoin-mainnet.status.tatum.io) | | [bitcoin-testnet.status.tatum.io](https://bitcoin-testnet.status.tatum.io) | | [bitcoin-testnet4.status.tatum.io](https://bitcoin-testnet4.status.tatum.io) | | [dogecoin-mainnet.status.tatum.io](https://dogecoin-mainnet.status.tatum.io) | | [dogecoin-testnet.status.tatum.io](https://dogecoin-testnet.status.tatum.io) | | [eos-mainnet-archive.status.tatum.io](https://eos-mainnet-archive.status.tatum.io) | | [ethereum-mainnet-archive.status.tatum.io](https://ethereum-mainnet-archive.status.tatum.io) | | [ethereum-mainnet.status.tatum.io](https://ethereum-mainnet.status.tatum.io) | | [ethereum-sepolia-archive.status.tatum.io](https://ethereum-sepolia-archive.status.tatum.io) | | [ethereum-holesky-archive.status.tatum.io](https://ethereum-holesky-archive.status.tatum.io) | | [ethereum-hoodi-archive.status.tatum.io](https://ethereum-hoodi-archive.status.tatum.io) | | [ethereum-mainnet.status.tatum.io](https://ethereum-mainnet.status.tatum.io) | | [flare-coston-archive.status.tatum.io](https://flare-coston-archive.status.tatum.io) | | [flare-coston2-archive.status.tatum.io](https://flare-coston2-archive.status.tatum.io) | | [flare-songbird-archive.status.tatum.io](https://flare-songbird-archive.status.tatum.io) | | [flare-mainnet-archive.status.tatum.io](https://flare-mainnet-archive.status.tatum.io) | | [haqq-mainnet-archive.status.tatum.io](https://haqq-mainnet-archive.status.tatum.io) | | [haqq-mainnet.status.tatum.io](https://haqq-mainnet.status.tatum.io) | | [haqq-testnet.status.tatum.io](https://haqq-testnet.status.tatum.io) | | [chiliz-mainnet.status.tatum.io](https://chiliz-mainnet.status.tatum.io) | | [chiliz-mainnet-archive.status.tatum.io](https://chiliz-mainnet-archive.status.tatum.io) | | [litecoin-mainnet.status.tatum.io](https://litecoin-mainnet.status.tatum.io) | | [litecoin-testnet.status.tatum.io](https://litecoin-testnet.status.tatum.io) | | [optimism-mainnet-archive.status.tatum.io](https://optimism-mainnet-archive.status.tatum.io) | | [polygon-mainnet-archive.status.tatum.io](https://polygon-mainnet-archive.status.tatum.io) | | [polygon-mainnet.status.tatum.io](https://polygon-mainnet.status.tatum.io) | | [horizen-eon-mainnet-archive.status.tatum.io](https://horizen-eon-mainnet-archive.status.tatum.io) | | [horizen-eon-gobi.status.tatum.io](https://horizen-eon-gobi.status.tatum.io) | | [bsc-mainnet-archive.status.tatum.io](https://bsc-mainnet-archive.status.tatum.io) | | [polygon-amoy-archive.status.tatum.io](https://polygon-amoy-archive.status.tatum.io) | | [polygon-amoy.status.tatum.io](https://polygon-amoy.status.tatum.io) | | [tron-mainnet-archive.status.tatum.io](https://tron-mainnet-archive.status.tatum.io) | | [arbitrum-one-mainnet-archive.status.tatum.io](https://arbitrum-one-mainnet-archive.status.tatum.io) | | [ethereum-classic-mainnet-archive.status.tatum.io](https://ethereum-classic-mainnet-archive.status.tatum.io) | | [zcash-mainnet.status.tatum.io](https://zcash-mainnet.status.tatum.io) | | [ripple-mainnet.status.tatum.io](https://ripple-mainnet.status.tatum.io) | | [ripple-testnet.status.tatum.io](https://ripple-testnet.status.tatum.io) | | [bitcoin-cash-mainnet.status.tatum.io](https://bitcoin-cash-mainnet.status.tatum.io) | | [kaia-mainnet.status.tatum.io](https://kaia-mainnet.status.tatum.io) | | [kaia-mainnet-archive.status.tatum.io](https://kaia-mainnet-archive.status.tatum.io) | | [klaytn-baobab.status.tatum.io](https://klaytn-baobab.status.tatum.io) | | [klaytn-baobab-archive.status.tatum.io](https://klaytn-baobab-archive.status.tatum.io) | | [avalanche-c-mainnet-archive.status.tatum.io](https://avalanche-c-mainnet-archive.status.tatum.io) | | [solana-mainnet.status.tatum.io](https://solana-mainnet.status.tatum.io) | | [solana-devnet.status.tatum.io](https://solana-devnet.status.tatum.io) | | [celo-mainnet-archive.status.tatum.io](https://celo-mainnet-archive.status.tatum.io) | | [celo-testnet-archive.status.tatum.io](https://celo-testnet-archive.status.tatum.io) | | [tezos-testnet.status.tatum.io](https://tezos-testnet.status.tatum.io) | | [tezos-mainnet.status.tatum.io](https://tezos-mainnet.status.tatum.io) | | [algorand-mainnet-algod.status.tatum.io](https://algorand-mainnet-algod.status.tatum.io) | | [algorand-testnet-algod.status.tatum.io](https://algorand-testnet-algod.status.tatum.io) | | [algorand-mainnet-indexer.status.tatum.io](https://algorand-mainnet-indexer.status.tatum.io) | | [algorand-testnet-indexer.status.tatum.io](https://algorand-testnet-indexer.status.tatum.io) | | [cardano-mainnet.status.tatum.io](https://cardano-mainnet.status.tatum.io) | | [cardano-preprod.status.tatum.io](https://cardano-preprod.status.tatum.io) | | [xinfin-mainnet-archive.status.tatum.io](https://xinfin-mainnet-archive.status.tatum.io) | | [stellar-mainnet-archive.status.tatum.io](https://stellar-mainnet-archive.status.tatum.io) | | [base-mainnet-archive.status.tatum.io](https://base-mainnet-archive.status.tatum.io) | | [kadena-mainnet.status.tatum.io](https://kadena-mainnet.status.tatum.io) | | [kadena-testnet.status.tatum.io](https://kadena-testnet.status.tatum.io) | | [rostrum-mainnet.status.tatum.io](https://rostrum-mainnet.status.tatum.io) | | [cronos-mainnet-archive.status.tatum.io](https://cronos-mainnet-archive.status.tatum.io) | | [fantom-mainnet-archive.status.tatum.io](https://fantom-mainnet-archive.status.tatum.io) | | [iota-mainnet.status.tatum.io](https://iota-mainnet.status.tatum.io) | ### Load Balancer Load balancer is used managing RPC calls to nodes in a blockchain network. It maintains a list of available nodes and their status, and it automatically selects the most responsive node for subsequent RPC calls. > **_For use of the Load Balancer, you don't need to know how it is working!._** Load Balancer works automatically in the background and selects the most responsive node for subsequent RPC calls. You can use the SDK without any knowledge of the Load Balancer. Load Balancer implementation is available in [LoadBalancerRpc.ts](https://github.com/tatumio/tatum-js/blob/master/src/service/rpc/generic/LoadBalancerRpc.ts) Using a load balancer to distribute traffic across multiple nodes, as opposed to routing all traffic to a single node, has several advantages: - **Improved Performance and Responsiveness:** Load balancers can distribute network or application traffic across several servers, which can help prevent any single server from becoming a bottleneck. As a result, users often experience faster response times. - **Scalability:** Load balancers enable you to handle larger amounts of traffic by simply adding more servers to the pool. This makes it easier to scale your infrastructure as your needs grow. - **Redundancy and High Availability:** If a server goes down, a load balancer can automatically reroute traffic to the remaining online servers. This ensures that your service remains available even in the face of hardware failures or other issues. - **Prevents Overloading of Nodes:** Load balancers can prevent any single server from being overloaded with too many requests, which can degrade the performance of the server and impact user experience. - **Efficient Use of Resources:** By distributing the load, you can make sure that all your servers are being used efficiently, rather than having some servers idle while others are overloaded. - **Flexibility and Maintenance:** With a load balancer, you can take servers offline for maintenance without disrupting service. The load balancer will simply stop sending traffic to the offline server. - **Better User Experience:** Ultimately, all of these benefits can lead to a better user experience, with faster response times and higher availability of services. #### Initialization At start the Load Balancer is initialized with a list of nodes. List of nodes are dynamically fetched from the remote server. There is also option to pass your custom list of nodes instead of the dynamic list. From the list of the nodes is randomly selected one node as a primary node, which is kept as a primary node until first load balancing is performed. The Load Balancer maintain lists of two types of nodes, normal and archive nodes. #### Load Balancing The load balancing process is running in the background and every minute it checks the status of all nodes in the list. The status of each node is determined by making a request to the node's URL and checking the response. The fastest responding node in each category is then selected as the active node for that normal and archive category. The selected nodes are then used for subsequent RPC calls. #### Error Handling If a RPC call fails, failure is logged, and the current active node is marked as failed, and load balancer selects a new active node. #### Destroy When you need to stop load balancer, you should can call `destroy` method. This method stops the load balancing process on the background. #### List of nodes The list of nodes is dynamically fetched from the remote server and it is defined for every blockchain. Here are the list of nodes for each blockchain: | Nodes List | | -------------------------------------------------------------------------------------------------------------------------- | | [rpc.tatum.io/bitcoin-mainnet/list.json](https://rpc.tatum.io/bitcoin-mainnet/list.json) | | [rpc.tatum.io/bitcoin-testnet/list.json](https://rpc.tatum.io/bitcoin-testnet/list.json) | | [rpc.tatum.io/dogecoin-mainnet/list.json](https://rpc.tatum.io/dogecoin-mainnet/list.json) | | [rpc.tatum.io/dogecoin-testnet/list.json](https://rpc.tatum.io/dogecoin-testnet/list.json) | | [rpc.tatum.io/eos-mainnet-archive/list.json](https://rpc.tatum.io/eos-mainnet-archive/list.json) | | [rpc.tatum.io/ethereum-mainnet-archive/list.json](https://rpc.tatum.io/ethereum-mainnet-archive/list.json) | | [rpc.tatum.io/ethereum-mainnet/list.json](https://rpc.tatum.io/ethereum-mainnet/list.json) | | [rpc.tatum.io/ethereum-hoodi-archive/list.json](https://rpc.tatum.io/ethereum-hoodi-archive/list.json) | | [rpc.tatum.io/ethereum-sepolia-archive/list.json](https://rpc.tatum.io/ethereum-sepolia-archive/list.json) | | [rpc.tatum.io/ethereum-holesky-archive/list.json](https://rpc.tatum.io/ethereum-holesky-archive/list.json) | | [rpc.tatum.io/ethereum-sepolia/list.json](https://rpc.tatum.io/ethereum-sepolia/list.json) | | [rpc.tatum.io/flare-coston-archive/list.json](https://rpc.tatum.io/flare-coston-archive/list.json) | | [rpc.tatum.io/flare-coston2-archive/list.json](https://rpc.tatum.io/flare-coston2-archive/list.json) | | [rpc.tatum.io/flare-mainnet-archive/list.json](https://rpc.tatum.io/flare-mainnet-archive/list.json) | | [rpc.tatum.io/flare-songbird-archive/list.json](https://rpc.tatum.io/flare-songbird-archive/list.json) | | [rpc.tatum.io/haqq-mainnet-archive/list.json](https://rpc.tatum.io/haqq-mainnet-archive/list.json) | | [rpc.tatum.io/haqq-mainnet/list.json](https://rpc.tatum.io/haqq-mainnet/list.json) | | [rpc.tatum.io/haqq-testnet/list.json](https://rpc.tatum.io/haqq-testnet/list.json) | | [rpc.tatum.io/chiliz-mainnet/list.json](https://rpc.tatum.io/chiliz-mainnet/list.json) | | [rpc.tatum.io/chiliz-mainnet-archive/list.json](https://rpc.tatum.io/chiliz-mainnet-archive/list.json) | | [rpc.tatum.io/litecoin-mainnet/list.json](https://rpc.tatum.io/litecoin-mainnet/list.json) | | [rpc.tatum.io/litecoin-testnet/list.json](https://rpc.tatum.io/litecoin-testnet/list.json) | | [rpc.tatum.io/optimism-mainnet-archive/list.json](https://rpc.tatum.io/optimism-mainnet-archive/list.json) | | [rpc.tatum.io/polygon-mainnet-archive/list.json](https://rpc.tatum.io/polygon-mainnet-archive/list.json) | | [rpc.tatum.io/polygon-mainnet/list.json](https://rpc.tatum.io/polygon-mainnet/list.json) | | [rpc.tatum.io/horizen-eon-mainnet-archive/list.json](https://rpc.tatum.io/horizen-eon-mainnet-archive/list.json) | | [rpc.tatum.io/horizen-eon-gobi/list.json](https://rpc.tatum.io/horizen-eon-gobi/list.json) | | [rpc.tatum.io/bsc-mainnet-archive/list.json](https://rpc.tatum.io/bsc-mainnet-archive/list.json) | | [rpc.tatum.io/polygon-amoy-archive/list.json](https://rpc.tatum.io/polygon-amoy-archive/list.json) | | [rpc.tatum.io/polygon-amoy/list.json](https://rpc.tatum.io/polygon-amoy/list.json) | | [rpc.tatum.io/tron-mainnet-archive/list.json](https://rpc.tatum.io/tron-mainnet-archive/list.json) | | [rpc.tatum.io/arbitrum-one-mainnet-archive/list.json](https://rpc.tatum.io/arbitrum-one-mainnet-archive/list.json) | | [rpc.tatum.io/ethereum-classic-mainnet-archive/list.json](https://rpc.tatum.io/ethereum-classic-mainnet-archive/list.json) | | [rpc.tatum.io/zcash-mainnet/list.json](https://rpc.tatum.io/zcash-mainnet/list.json) | | [rpc.tatum.io/ripple-mainnet/list.json](https://rpc.tatum.io/ripple-mainnet/list.json) | | [rpc.tatum.io/ripple-testnet/list.json](https://rpc.tatum.io/ripple-testnet/list.json) | | [rpc.tatum.io/kaia-mainnet/list.json](https://rpc.tatum.io/kaia-mainnet/list.json) | | [rpc.tatum.io/kaia-mainnet-archive/list.json](https://rpc.tatum.io/kaia-mainnet-archive/list.json) | | [rpc.tatum.io/klaytn-baobab/list.json](https://rpc.tatum.io/klaytn-baobab/list.json) | | [rpc.tatum.io/klaytn-baobab-archive/list.json](https://rpc.tatum.io/klaytn-baobab-archive/list.json) | | [rpc.tatum.io/bitcoin-cash-mainnet/list.json](https://rpc.tatum.io/bitcoin-cash-mainnet/list.json) | | [rpc.tatum.io/avalanche-c-mainnet-archive/list.json](https://rpc.tatum.io/avalanche-c-mainnet-archive/list.json) | | [rpc.tatum.io/solana-mainnet/list.json](https://rpc.tatum.io/solana-mainnet/list.json) | | [rpc.tatum.io/solana-devnet/list.json](https://rpc.tatum.io/solana-devnet/list.json) | | [rpc.tatum.io/celo-mainnet-archive/list.json](https://rpc.tatum.io/celo-mainnet-archive/list.json) | | [rpc.tatum.io/celo-testnet-archive/list.json](https://rpc.tatum.io/celo-testnet-archive/list.json) | | [rpc.tatum.io/tezos-testnet/list.json](https://rpc.tatum.io/tezos-testnet/list.json) | | [rpc.tatum.io/tezos-mainnet/list.json](https://rpc.tatum.io/tezos-mainnet/list.json) | | [rpc.tatum.io/algorand-mainnet-algod/list.json](https://rpc.tatum.io/algorand-mainnet-algod/list.json) | | [rpc.tatum.io/algorand-testnet-algod/list.json](https://rpc.tatum.io/algorand-testnet-algod/list.json) | | [rpc.tatum.io/algorand-mainnet-indexer/list.json](https://rpc.tatum.io/algorand-mainnet-indexer/list.json) | | [rpc.tatum.io/algorand-testnet-indexer/list.json](https://rpc.tatum.io/algorand-testnet-indexer/list.json) | | [rpc.tatum.io/cardano-mainnet/list.json](https://rpc.tatum.io/cardano-mainnet/list.json) | | [rpc.tatum.io/cardano-preprod/list.json](https://rpc.tatum.io/cardano-preprod/list.json) | | [rpc.tatum.io/xinfin-mainnet-archive/list.json](https://rpc.tatum.io/xinfin-mainnet-archive/list.json) | | [rpc.tatum.io/stellar-mainnet-archive/list.json](https://rpc.tatum.io/stellar-mainnet-archive/list.json) | | [rpc.tatum.io/base-mainnet-archive/list.json](https://rpc.tatum.io/base-mainnet-archive/list.json) | | [rpc.tatum.io/kadena-mainnet/list.json](https://rpc.tatum.io/kadena-mainnet/list.json) | | [rpc.tatum.io/kadena-testnet/list.json](https://rpc.tatum.io/kadena-testnet/list.json) | | [rpc.tatum.io/rostrum-mainnet/list.json](https://rpc.tatum.io/rostrum-mainnet/list.json) | | [rpc.tatum.io/cronos-mainnet-archive/list.json](https://rpc.tatum.io/cronos-mainnet-archive/list.json) | | [rpc.tatum.io/fantom-mainnet-archive/list.json](https://rpc.tatum.io/fantom-mainnet-archive/list.json) | | [rpc.tatum.io/iota-mainnet/list.json](https://rpc.tatum.io/iota-mainnet/list.json) | Following pattern defines the URL for fetching the list of nodes: ``` https://rpc.tatum.io/${network}/list.json ``` Networks enum is available in the [Network.ts](https://github.com/tatumio/tatum-js/blob/master/src/dto/Network.ts) For instance if we will need Bitcoin mainnet nodes, we will use this URL: ``` curl https://rpc.tatum.io/bitcoin-mainnet/list.json ``` The response is a list of nodes with their url, type (0 - normal, 1 - archive) and location. ```json [ { "location": "Sydney", "type": 0, "url": "https://02-sydney-007-01.rpc.tatum.io/" }, { "location": "Tokyo", "type": 0, "url": "https://02-tokyo-007-02.rpc.tatum.io/" }, { "location": "Dallas", "type": 0, "url": "https://02-dallas-007-03.rpc.tatum.io/" }, { "location": "Sao Paulo", "type": 0, "url": "https://02-saopaulo-007-04.rpc.tatum.io/" }, { "location": "Warsaw", "type": 0, "url": "https://01-warsaw-007-05.rpc.tatum.io/" } ] ``` Load Balancer selects from this list the most responsive node. ### Usage #### Default config ```typescript const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM }) const info = await tatum.rpc.chainId() tatum.rpc.destroy() ``` #### Custom RPC node list ```typescript const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM, rpc: { nodes: [ { url: 'https://api.tatum.io/v3/blockchain/node/ethereum-mainnet', type: RpcNodeType.NORMAL, }, ], allowedBlocksBehind: 20, oneTimeLoadBalancing: false, }, }) const info = await tatum.rpc.chainId() tatum.rpc.destroy() ``` ## Documentation - [Documentation and Guides](https://docs.tatum.io) to get started with Tatum SDK - [Documentation section](https://github.com/tatumio/tatum-js/tree/master/docs) for more details. ## Examples Explore various applications that utilize the Tatum SDK. These examples help illustrate the SDK's functionality and offer a starting point for developers looking to integrate similar features into their applications. ![Metamask notifications](https://github.com/tatumio/example-apps/blob/master/Metamask/notifications/public/demo.png) - [Metamask notifications](https://github.com/tatumio/example-apps/tree/master/Metamask/notifications) - [Metamask portfolio](https://github.com/tatumio/example-apps/tree/master/Metamask/portfolio) - [Metamask transfer](https://github.com/tatumio/example-apps/tree/master/Metamask/transfer) ## 🌐 Extension Ecosystem ### Quickstart Import any Tatum SDK extension to your project and start using it right away. ```typescript import { TatumSDK, Ethereum, Network, ApiVersion } from '@tatumio/tatum' import { HelloWorldExtension } from '@tatumio/hello-world' const tatumSdk = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM_SEPOLIA, configureExtensions: [HelloWorldExtension], }) ``` After that you can use the extension in your code with full intellisense. ```typescript await tatumSdk.extension(HelloWorldExtension).sayHello() ``` ### Wallet Providers Tatum SDK supports wallet provider extensions for various wallets. You can use them to integrate your application with the wallet of your choice. ```typescript import { TatumSDK, Ethereum, Network, ApiVersion } from '@tatumio/tatum' import { EvmWalletProvider } from '@tatumio/evm-wallet-provider' const tatumSdk = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM_SEPOLIA, configureWalletProviders: [EvmWalletProvider], }) ``` Usage for wallet providers is similar to the extensions. ```typescript await tatumSdk.walletProvider.use(EvmWalletProvider).getWallet() ``` 🔍 Check out our [built-in MetaMask wallet provider](./src/service/walletProvider/metaMask/metamask.wallet.provider.ts) 📚 **Learn more about Tatum SDK Extension ecosystem here - [Tatum SDK Extensions](https://github.com/tatumio/ecosystem-addons)** ## Legacy versions Older versions of the Tatum SDK has been moved to long living branches [`Tatum SDK V1`](https://github.com/tatumio/tatum-js/tree/v1) and [`Tatum SDK V2`](https://github.com/tatumio/tatum-js/tree/v2). ## 🤝 Contributing We appreciate your interest in contributing to the Tatum SDK. Here's a guide to help you make meaningful contributions: ### Local Testing Before making a pull request, ensure you've thoroughly tested your changes with a local client. ### Unit Tests Include unit test coverage for any new code you're adding. This helps in maintaining the quality and reliability of our SDK. ### Update the Changelog For every contribution, it's essential to document your changes in the changelog. The changelog keeps track of all the changes, updates, and fixes we make to our SDK. Use the provided format: ```markdown ## [Version Number] - YYYY.MM.DD ### Added/Updated/Fixed/Changed - Description of the change ``` For instance: ```markdown ## [3.0.10] - 2023.08.11 ### Added - New feature XYZ ``` ### Update `package.json` Before creating a pull request or releasing a new version, ensure the `version` in `package.json` is updated to reflect the new release number. ### Release Consideration Your changes will be released after merging the pull request. ### How to add support for new RPC chain - Add new chain to the [Network.ts](./src/dto/Network.ts) enum (Check also LOAD_BALANCER_NETWORKS constants) - Add new class to the [tatum.ts](./src/service/tatum/tatum.ts) file - Add new chain getClient method in the [Utils.ts](./src/util/util.shared.ts) file - Add new chain CURRENCY_NAMES and DECIMALS constants in the [constants.ts](./src/util/constant.ts) file - Update README.md with new chain for status page and list.json - Add E2E test --- 🙌 Thank you for helping make Tatum SDK better! Your contributions play a crucial role in its continuous improvement and growth. ### 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](https://github.com/tatumio/tatum-js/issues/new/choose).

Crypto & Blockchain API Tools
400 Github Stars
tatum-kms
Open Source

tatum-kms

# Tatum Key Management System (KMS) **Tatum Key Management System (KMS)** is a comprehensive solution for Tatum-powered applications. > **Warning** > > Important notice about using KMS with ETH and CELO: Please upgrade to version 6.2.3 or newer (all previous versions depend on https://ethgasstation.info which will stop working from 12.12.2022) KMS securely stores private keys and mnemonics of blockchain wallets. KMS periodically pulls pending transactions to sign from Tatum, signs them locally using the stored private keys and mnemonics, and broadcasts them to the blockchain. <img src="src/img/kms_overview.png" width="50%" height="50%"/> KMS supports the following blockchains: * Algorand (ALGO) * Bitcoin (BTC) * Bitcoin Cash (BCH) * BNB Beacon Chain (BSC) * BNB Smart Chain (BNB) * Celo (CELO) * Dogecoin (DOGE) * Elrond (EGLD) * Ethereum (ETH) including ERC-20 tokens * Harmony (ONE) * Klaytn (KLAY) * KuCoin Community Chain (KCS) * Litecoin (LTC) * Polygon (MATIC) * Solana (SOL) * Stellar (XLM) * TRON (TRON) * VeChain (VET) * XinFin (XDC) * XRP (XRP) For more information about KMS, see our [user documentation](https://docs.tatum.io/docs/tatum-key-management-system-kms). ## Secure storage KMS generates and stores the private keys and mnemonic in an encrypted file, `wallet.dat`, in the local file system. This wallet storage file is encrypted using the AES-GCM-256 cipher. The password that is used to encrypt the wallet storage file is the most sensitive asset in this architecture. The password is never passed as a parameter. You can enter the password into KMS using either of the following methods: * Enter the password manually at KMS start. The password is stored in the memory only during the daemon runtime. * Store the password in [VGS Vault](https://www.verygoodsecurity.com/), [Microsoft Azure Key Vault](https://azure.microsoft.com/en-us/services/key-vault/), or [AWS Secrets Manager](https://aws.amazon.com/secrets-manager/). The password is obtained during KMS start and is stored in the memory only during the daemon runtime. In this setup, the private keys and mnemonics never leave your perimeter. If someone gains unauthorized access to the file system, they cannot get the private keys and mnemonics because they are encrypted. ## Signature IDs vs. Private keys and mnemonics Every wallet that is stored inside KMS has a unique identifier called **signature ID**. The signature ID is used in communication with the Tatum API and represents the wallet used by the specific operation. >**NOTE:** You can have up to 25,000 signature IDs per one blockchain and one Tatum API key. If you exceed this limit, you get an error message, and KMS stops signing your transactions until you adjust your data to respect the limit. The Tatum API accepts the following representations of the signature ID in requests: * A signature ID that represents the **private key** type of a wallet In API calls like [/v3/bitcoin/transaction](https://docs.tatum.io/reference/btcgeneratewallet#operation/BtcTransferBlockchain), `signatureId` in the request represents the private key type of the wallet. ``` bash:$ tatum-kms storemanagedprivatekey BTC { "signatureId": "e3015fc0-2112-4c8a-b8bf-353b86f63ba5" } ``` * A signature ID that represents the **mnemonic** type of a wallet In API calls like [/v3/offchain/bitcoin/transfer](https://docs.tatum.io/reference/btctransfer#operation/BtcTransfer), `signatureId` in the request represents the mnemonic type of the wallet. ``` bash:$ tatum-kms generatemanagedwallet BTC { "signatureId": "e3015fc0-2112-4c8a-b8bf-353b86f63ba5", "xpub": "xpub6EsCk1uU6cJzqvP9CdsTiJwT2rF748YkPnhv5Qo8q44DG7nn2vbyt48YRsNSUYS44jFCW9gwvD9kLQu9AuqXpTpM1c5hgg9PsuBLdeNncid" } ``` * A signature ID that represents the **mnemonic**/**index** type of a wallet In API calls like [/v3/offchain/ethereum/transfer](https://docs.tatum.io/reference/btctransfer#operation/EthTransfer), the index of the specified private key generated from the mnemonic must be used together with `signatureId`. ``` bash:$ tatum-kms generatemanagedwallet BTC { "signatureId": "e3015fc0-2112-4c8a-b8bf-353b86f63ba5", "xpub": "xpub6EsCk1uU6cJzqvP9CdsTiJwT2rF748YkPnhv5Qo8q44DG7nn2vbyt48YRsNSUYS44jFCW9gwvD9kLQu9AuqXpTpM1c5hgg9PsuBLdeNncid" } ``` ## Set up and use KMS on your site To get KMS up and running on your site on the mainnet, complete the following steps: 1. [Install KMS](#install-kms) on your local environment. KMS is installed as a set of CLI tools and commands to generate and store wallets and private keys securely. You can install KMS from npm or via Docker. 1. Store the existing mnemonics and private keys in KMS, or generate new mnemonics and private keys using KMS. For more information, see the [KMS commands](#kms-commands). 1. Implement the [four-eye principle](#implement-the-four-eye-principle) by setting up a service to store the IDs of the transactions that need to be signed. This is another security level in KMS that verifies that the transactions to sign are yours. 1. [Run KMS in daemon mode](#run-kms-in-daemon-mode) so it can periodically check for transactions to sign. 1. When performing operations that must be signed with the private key or mnemonic (such as transferring funds, minting NFT, and so on), use the KMS schemas to build the body of the API requests as specified in the [API Reference](https://docs.tatum.io/reference/welcome-to-the-tatum-api-reference). This way, you will be using the signature ID instead of the private key or a combination of the signature ID and the index instead of the mnemonic. ## Install KMS ### Supported operating systems You can run KMS on the following operating systems: - **macOS:** Natively or via [Docker](https://hub.docker.com/repository/docker/tatumio/tatum-kms) - **Unix:** Natively or via [Docker](https://hub.docker.com/repository/docker/tatumio/tatum-kms) - **MS Windows:** Only via [Docker](https://hub.docker.com/repository/docker/tatumio/tatum-kms) We recommend that you run KMS from the [Docker image](https://hub.docker.com/repository/docker/tatumio/tatum-kms) regardless of the operating system used. ### Environment variables Create file `.env` file with the following parameters and replace the placeholders with your values: ``` # required TATUM_API_KEY=XXXXX-YOUR-API-KEY # one of the following setups is required: password, VGS, Azure, or AWS # password setup TATUM_KMS_PASSWORD=XXXXPASSWORD # VGS setup TATUM_KMS_VGS_USERNAME=XXXXUSERNAME TATUM_KMS_VGS_PASSWORD=XXXXPASSWORDVGS TATUM_KMS_VGS_ALIAS=XXXVSGALIAS # Azure setup TATUM_KMS_AZURE_SECRETVERSION=XXVERSION TATUM_KMS_AZURE_SECRETNAME=XXSECRETNAME TATUM_KMS_AZURE_VAULTURL=XXXXVAULTURL # AWS setup TATUM_KMS_AWS_REGION=us-east-1 TATUM_KMS_AWS_SECRET_NAME=YOUR_KMS_SECRET_NAME TATUM_KMS_AWS_ACCESS_KEY_ID=AKIAYWGKDBVRGMCASWIE TATUM_KMS_AWS_SECRET_ACCESS_KEY=ZxDq62BZGyGe2CzwnVjL/IH8NnJG5Fu0isN7wev9 TATUM_KMS_AWS_SECRET_KEY=pwd # Debug mode. if true/1, it will expose data from signEthKMSTransaction() method to the console TATUM_KMS_DEBUG_MODE=true/false/1/0 ``` ### Install KMS from npm 1. Install KMS globally: ``` npm i -g @tatumio/tatum-kms ``` or ``` yarn global add @tatumio/tatum-kms ``` 1. Use ```.env``` file to configure Tatum KMS 1. via ```--envFile=/path/to/.env``` ``` tatum-kms --envFile=/path/to/.env getaddress 11111111-1111-1111-1111-111111111111 0 ``` 1. via environment variables directly ``` TATUM_API_KEY=XXXXX-YOUR-API-KEY tatum-kms --help ``` 1. via predefined environment vars on global level ``` export TATUM_API_KEY=XXXXX-YOUR-API-KEY tatum-kms --help ``` >**IMPORTANT!** NodeJS >=18.0 are required. KMS does **not** work on older versions. ### Install KMS via Docker 1. Pull the `tatum-kms` image: ``` docker pull tatumio/tatum-kms ``` 1. Navigate to the home directory: ``` cd $HOME ``` 1. Use pre-created ```.env``` file to configure Tatum KMS via ```--env-file .env```: 1. Map the Docker volume to the local storage (your home folder). For more details, refer to the [Docker user documentation](https://docs.docker.com/storage/volumes/). Once you have mapped the Docker volume, KMS is ready to be run as a Docker container. To interactively communicate with KMS and run various [KMS commands](#kms-commands), use the `docker run` command: ``` docker run -it --env-file .env -v $HOME/.tatumrc:/home/node/.tatumrc tatumio/tatum-kms --help docker run -it --env-file .env -v $HOME/.tatumrc:/home/node/.tatumrc tatumio/tatum-kms generatemanagedwallet BTC docker run -it --env-file .env -v $HOME/.tatumrc:/home/node/.tatumrc tatumio/tatum-kms storemanagedprivatekey BTC ``` >**NOTE:** You can shorten the command syntax and use it as follows: ``` docker run ${COMMON_PARAMS} tatumio/tatum-kms generatemanagedwallet BTC ``` >where `COMMON_PARAMS` can be exported as all the flags necessary for running the container. ## Implement the four-eye principle To verify whether a transaction to sign with KMS is indeed yours, implement the **four-eye-principle** (also referred to as "4-eye principle"). This principle ensures that pending transactions are controlled in Tatum and in your system. Every time a transaction from Tatum is fetched to be signed, it is validated against an external trusted server using a simple HTTP GET operation: `your_external_url/transaction_id` If the response is `2xx`, KMS signs the transaction. Otherwise, the transaction is skipped and is not signed, and you should take the appropriate steps on your end to fix the situation. >**NOTE:** Implementing the four-eye-principle is mandatory on the mainnet to make the production environment more secure. <img src="src/img/kms_4eye.png" width="75%" height="75%"/> To enable the four-eye-principle: 1. Set up an application server that will hold the list of valid transactions to sign. 1. Add the `externalUrl` parameter to KMS and set it to your application server: ``` tatum-kms daemon --externalUrl=http://192.168.57.63 ``` ## Run KMS in daemon mode ``` tatum-kms daemon ``` or ``` docker run -d --env-file .env -v $HOME:/root/.tatumrc tatumio/tatum-kms daemon ``` When KMS runs as a daemon, it periodically checks for any new pending transactions to sign. After successful startup, the daemon requires the password to the wallet storage file. The file and the data in the file are encrypted, and the password is stored in the memory only during the daemon runtime. ``` bash:$ tatum-kms daemon Enter password to decrypt wallet store: ``` Alternatively, you can provide the password via an environment variable: ``` TATUM_KMS_PASSWORD=password ``` ### Change the frequency of checking for the pending transactions Checking for the pending transactions consumes credits from the monthly credit allowance associated with your API key: 1 credit for every 500 signature IDs per API call. For more information about the credits, see [Plans and Limits](https://docs.tatum.io/docs/plans-limits). By default, KMS checks for the pending transactions to sign every 5 seconds. To change the frequency of the check, use the `--period` parameter and set it the required number of seconds: ``` tatum-kms daemon --period=15 ``` ### Change the path to the wallet storage file By default, the [wallet storage file](#secure-storage) is saved under the `.tatumrc` folder in your home directory (for example, `/home/admin/.tatumrc/wallet.dat`). To change the path to the wallet storage file, use the `--path` parameter and set it to the new path: ``` tatum-kms daemon --path=/path/to/wallet/storage/file/wallet.dat ``` ### Check for the pending transactions only on some blockchains By default, KMS checks for the pending transaction on [all supported blockchains](#tatum-key-management-system-kms). To check for the transactions only on some blockchains, use the `--chain` parameter and set it to the list of the blockchains to check separated with a comma (`,`): ``` tatum-kms daemon --chain=BTC,LTC,ETH ``` ## KMS commands To see all available KMS commands, refer to the KMS help: ``` tatum-kms --help ``` When KMS runs in [daemon mode](#run-kms-in-daemon-mode), use the following commands to communicate with the daemon and modify it: * `generatewallet chain` generates a wallet on the specified blockchain (`chain`) and echos it to the output. This command does **not** add the generated wallet to the wallets managed by KMS. ``` bash:$ tatum-kms generatewallet BTC { "mnemonic": "urge pulp usage sister evidence arrest palm math please chief egg abuse", "xpub": "xpub6EsCk1uU6cJzqvP9CdsTiJwT2rF748YkPnhv5Qo8q44DG7nn2vbyt48YRsNSUYS44jFCW9gwvD9kLQu9AuqXpTpM1c5hgg9PsuBLdeNncid" } ``` * `generatemanagedwallet chain` generates a wallet on the specified blockchain (`chain`) and adds it to the managed wallets. This command echos the signature ID of the wallet to be used in requests to the Tatum API and the extended public key of the wallet to pair with [virtual accounts](https://docs.tatum.io/docs/virtual-accounts). ``` bash:$ tatum-kms generatemanagedwallet BTC { "signatureId": "e3015fc0-2112-4c8a-b8bf-353b86f63ba5", "xpub": "xpub6EsCk1uU6cJzqvP9CdsTiJwT2rF748YkPnhv5Qo8q44DG7nn2vbyt48YRsNSUYS44jFCW9gwvD9kLQu9AuqXpTpM1c5hgg9PsuBLdeNncid" } ``` * `storemanagedwallet chain` stores a mnemonic-based wallet on the specified blockchain (`chain`) and adds it to the managed wallets. This command echos the signature ID of the wallet to be used in requests to the Tatum API and the extended public key of the wallet to pair with with [virtual accounts](https://docs.tatum.io/docs/virtual-accounts). ``` bash:$ tatum-kms storemanagedwallet BTC { "signatureId": "e3015fc0-2112-4c8a-b8bf-353b86f63ba5", "xpub": "xpub6EsCk1uU6cJzqvP9CdsTiJwT2rF748YkPnhv5Qo8q44DG7nn2vbyt48YRsNSUYS44jFCW9gwvD9kLQu9AuqXpTpM1c5hgg9PsuBLdeNncid" } ``` * `storemanagedprivatekey chain` stores the private key of the wallet on the specified blockchain (`chain`) and adds it to the managed wallets. This command echos the signature ID of the wallet to be used in requests to the Tatum API. ``` bash:$ tatum-kms storemanagedprivatekey BTC { "signatureId": "e3015fc0-2112-4c8a-b8bf-353b86f63ba5" } ``` * `generatemanagedprivatekeybatch chain count` generates and stores the specified number of private keys (`count`) on the specified blockchain (`chain`). This command is useful when you want to pre-generate a large amount of managed private keys for later use. ``` bash:$ tatum-kms generatemanagedprivatekeybatch BTC 100 ``` * `getmanagedwallet signatureId` obtains the mnemonic or the private key from the wallet storage file for the wallet associated with the specified signature ID (`signatureId`). ``` bash:$ tatum-kms getmanagedwallet e3015fc0-2112-4c8a-b8bf-353b86f63ba5 { "mnemonic": "urge pulp usage sister evidence arrest palm math please chief egg abuse", "xpub": "xpub6EsCk1uU6cJzqvP9CdsTiJwT2rF748YkPnhv5Qo8q44DG7nn2vbyt48YRsNSUYS44jFCW9gwvD9kLQu9AuqXpTpM1c5hgg9PsuBLdeNncid", "testnet": false, "chain": "BTC" } ``` * `removewallet signatureId` removes the managed wallet associated with the specified signature ID (`signatureId`) from the wallet storage file. ``` bash:$ tatum-kms removewallet e3015fc0-2112-4c8a-b8bf-353b86f63ba5 ``` * `getprivatekey signatureId i` obtains the managed wallet associated with the specified signature ID (`signatureId`) from the wallet storage file and generates a private key for the specified derivation index (`i`). ``` bash:$ tatum-kms getprivatekey e3015fc0-2112-4c8a-b8bf-353b86f63ba5 3 { "privateKey": "L4TUX4PP4X5R9JqotwmHbEYXz3WLrw4FR7FfVmZJoSdMovCV2mEe" } ``` * `getaddress signatureId i` obtains the managed wallet associated with the specified signature ID (`signatureId`) from the wallet storage file and generates an address for the specified derivation index (`i`). ``` bash:$ tatum-kms getaddress e3015fc0-2112-4c8a-b8bf-353b86f63ba5 3 { "address": "13KvuMxDNT7jDffgSp7QtuLJq6fjpq1Ah7" } ``` * `export` exports all managed wallets. ``` bash:$ tatum-kms export { "e3015fc0-2112-4c8a-b8bf-353b86f63ba5": { "mnemonic": "urge pulp usage sister evidence arrest palm math please chief egg abuse", "xpub": "xpub6EsCk1uU6cJzqvP9CdsTiJwT2rF748YkPnhv5Qo8q44DG7nn2vbyt48YRsNSUYS44jFCW9gwvD9kLQu9AuqXpTpM1c5hgg9PsuBLdeNncid", "testnet": false, "chain": "BTC" } } ``` * `checkconfig`(for debugging) shows environment variables for Tatum KMS. ``` bash:$ tatum-kms checkconfig Version : 6.4.0 Wallet file path : ~/.tatumrc/wallet.dat Wallet exists : true Wallet store type : LOCAL Env file : .env TATUM_API_KEY : d2eb5c****************************** ... ``` * `report`(for debugging) shows report of system and requested wallets (+ warnings if they were found) ``` bash:$ tatum-kms report e3015fc0-2112-4c8a-b8bf-353b86f63ba5,11115fc0-2112-4c8a-b8bf-353b86f63111 { "system": { "kmsVersion": "7.0.6", "nodeVersion": "v18.18.2", "store": { "type": "LOCAL", "exists": true } }, "wallets": { "e3015fc0-2112-4c8a-b8bf-353b86f63ba5": { "type": "PRIVATE_KEY", "chain": "BTC", "testnet": true }, "11115fc0-2112-4c8a-b8bf-353b86f63111": { "type": "MNEMONIC", "chain": "ETH", "testnet": true, "warnings": [ "No xpub found" ] } }, "apiKey": "t-6111***************************************222222", "warnings": [ "Wallets file was is not accessible" ] } ``` ## Common issues ### Mnemonic-related error ``` error:: TypeError: Cannot read property 'mnemonic' of undefined ``` ***Possible reasons:*** * You used a mnemonic-based signature ID but the operation requires a signature ID based on the private key. * You correctly used the mnemonic-based signature ID but you did not specify the index of the private key. KMS generates the private key from the mnemonic that the signature ID holds. To generate the correct private key from the mnemonic, KMS needs to know the [index of the private key](#signature-ids-vs-private-keys-and-mnemonics) to generate (0-2^31-1). ### KMS_FAILED_TX for confirmed transaction Successful transaction in block returned failed notification in KMS. ***Possible reason:*** KMS waits for the transaction to be processed on-chain, but a timeout is set on the core API side (usually 10 seconds, though this can vary by chain). If the transaction isn’t confirmed within that window—perhaps due to a high network load—a notification about a failed transaction is issued. However, the transaction may still be confirmed later and developers can implement additional logic to detect such delayed confirmations.

Crypto & Blockchain Secret Management
206 Github Stars