Configuration options

Network

Every Tatum SDK instance must be initiated with the proper blockchain network. All operations performed later using this SDK will automatically use the network from the configuration.

📘

To see the list of all available blockchain protocols, check on GitHub

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

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

👍

TatumSDK is returning the correct types for the RPC submodule using generic types in the init() method. To see all the supported RPC types, check here.

API Version

Tatum SDK works with two versions of the Tatum API - version 3 and version 4. Each of the versions supports different operations, it's recommended to use version 4.

📘

Version 4 of the API supports the most up-to-date features and is set as a default value. The SDK by default tries to perform the calls against version 4 and fallbacks to version 3

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

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

API Keys

To use the Tatum API's you would need an API key, which you can obtain one at Tatum Dashboard for free.

Get API key For free. No commitment.

Don't have an API key?

Sign up to Dashboard and create your API keys today.
Get higher limits and use debugging tools.


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

const tatum = await TatumSDK.init<Ethereum>({
  network: Network.ETHEREUM,
  apiKey: {
   v3: 'YOUR_API_KEY_V3',
   v4: 'YOUR_API_KEY_V4'
})

Verbose mode

If you want to start the verbose logging mode to see requests and responses returned from the Tatum API, just set the config verbose: true.

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

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

Custom RPC provider URL

You can use any RPC provider for interacting with a blockchain. Just add your custom node provider inside rpc.nodes array. All other features from the SDK will work as expected, only the RPC calls will point to your custom node.

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

const tatum = await TatumSDK.init<Ethereum>({network: Network.ETHEREUM, rpcUrl: 'https://YOUR_CUSTOM_RPC_PROVIDER'})

const tatum = await TatumSDK.init<BaseEvmClass>({
    network: Network.ETHEREUM,
    verbose: true,
    rpc: {
       nodes: [
         {
           url: 'YOUR_CUSTOM_PROVIDER_URL',
           type: RpcNodeType.NORMAL,
        },
      ],
    },
})

Retry policy

There are some cases when requests fail to complete successfully. For instance, when you exceed request rate limitations or a network error occurs. To configure behavior when requests fail use

  • retryCount - specifies the maximum number of how many times the failed request is resent again until a successful response is returned, the default value is 1
  • retryDelay - specifies the number in milliseconds of how long it waits before the failed request is resent again, the default value is 1000
import {TatumSDK, Network, Ethereum} from '@tatumio/tatum'

const tatum = await TatumSDK.init<Ethereum>({
    network: Network.ETHEREUM, 
    retryCount: 5,
    retryDelay: 1500,
})

Logger module

TatumSDK allows you to inject a custom logger in case you already have one or want to tweak the settings of one provided by Tatum.

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

const logger = new TatumDevelopmentLogger({ level: LogLevel.DEBUG });

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

Or bring your own one entirely:

const logger = {
  trace(...args) {},
  debug(...args) {},
  info(...args) {},
  warn(...args) {},
  error(...args) {},
}

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

📘

You can read more on this topic on our Logging page.

Quiet mode

Enables quiet mode, overriding the provided or builtin logger. Disables logging from inside the SDK.

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

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