Configuration options
TatumSDK.init accepts options for the network, API version, API keys, verbose logging, custom RPC nodes, retry count and delay, a custom logger and quiet mode.
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, seesrc/dto/Network.tson GitHub.
import {TatumSDK, Network, Ethereum} from '@tatumio/tatum'
const tatum = await TatumSDK.init<Ethereum>({network: Network.ETHEREUM})
TatumSDK returns the correct types for the RPC submodule through the generic type of theinit()method. To see all the supported RPC types, seesrc/dto/rpc/index.tson GitHub.
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 the default value. To send the SDK's API calls to version 3 instead, setversion: ApiVersion.V3.
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, you need an API key. You can get one for free in the Tatum Dashboard.
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: '{YOUR_API_KEY}',
})Pass the API key as a string. The object form apiKey: { v3: '...', v4: '...' } still works but is deprecated.
Verbose mode
If you want to start the verbose logging mode to see requests and responses returned from the Tatum API, set the config verbose: true. The verbose option is deprecated; for new code, configure a logger instead.
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. Add your custom node provider to the rpc.nodes array, with type: RpcNodeType.NORMAL for a full node or type: RpcNodeType.ARCHIVE for an archive node. All other features from the SDK will work as expected, only the RPC calls will point to your custom node.
import {TatumSDK, Network, Ethereum, RpcNodeType} from '@tatumio/tatum'
const tatum = await TatumSDK.init<Ethereum>({
network: Network.ETHEREUM,
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 1retryDelay- 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, LogLevel, 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:
import { TatumSDK, Logger, Network, Ethereum } from "@tatumio/tatum"
const logger: Logger = {
trace(...args: unknown[]) {},
debug(...args: unknown[]) {},
info(...args: unknown[]) {},
warn(...args: unknown[]) {},
error(...args: unknown[]) {},
}
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, Network, Ethereum } from "@tatumio/tatum"
const tatum = await TatumSDK.init<Ethereum>({
network: Network.ETHEREUM,
quiet: true,
})Updated 8 days ago