hive-tx uses a global configuration object to manage API nodes, network settings, and request behavior. You can customize these settings to use your own nodes, adjust timeouts, or configure for different Hive networks.
Configuration Object
The configuration is exported from the main package:
import { config } from 'hive-tx'
console . log ( config . nodes ) // Array of API endpoints
console . log ( config . chain_id ) // Blockchain identifier
console . log ( config . timeout ) // Request timeout in ms
All settings can be modified at runtime:
config . timeout = 15_000 // Increase timeout to 15 seconds
config . retry = 5 // Reduce retry attempts
API Nodes
hive-tx uses multiple Hive API nodes for load balancing and automatic failover.
Default Nodes
config . nodes = [
'https://api.hive.blog' ,
'https://api.deathwing.me' ,
'https://api.openhive.network' ,
'https://rpc.mahdiyari.info' ,
'https://techcoderx.com' ,
'https://hiveapi.actifit.io' ,
'https://api.c0ff33a.uk'
]
When an API call fails, hive-tx automatically tries the next node in the list.
Custom Nodes
Replace the node list with your own infrastructure:
import { config } from 'hive-tx'
// Use only your nodes
config . nodes = [
'https://my-hive-node.example.com' ,
'https://backup-node.example.com'
]
Add Nodes
Append additional nodes while keeping defaults:
config . nodes . push ( 'https://my-custom-node.com' )
Using multiple nodes improves reliability. If one node is down or slow, requests automatically failover to the next available node.
REST API Nodes
Some operations use REST APIs instead of JSON-RPC. These nodes support the REST endpoints:
config . restNodes = [
'https://api.hive.blog' ,
'https://rpc.mahdiyari.info' ,
'https://techcoderx.com' ,
'https://hiveapi.actifit.io' ,
'https://api.c0ff33a.uk'
]
REST nodes are used for specific API methods like transaction status checks. They’re separate from the main RPC nodes.
import { config } from 'hive-tx'
config . restNodes = [
'https://my-rest-node.example.com'
]
REST node URLs should not have a trailing slash. For example, use https://api.hive.blog not https://api.hive.blog/.
Network Configuration
Chain ID
The chain ID ensures transactions are valid only on the intended network:
config . chain_id = 'beeab0de00000000000000000000000000000000000000000000000000000000'
This is Hive mainnet’s chain ID. For testnet:
// Hive testnet chain ID
config . chain_id = '18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e'
Address Prefix
The prefix used for public key formatting:
config . address_prefix = 'STM'
For testnet:
config . address_prefix = 'TST'
This affects how public keys are displayed:
Mainnet: STM8m5UgaFAAYQRuaNejYdS8FVLVp9Ss3K1qAVk5de6F8s3HnVbvA
Testnet: TST8m5UgaFAAYQRuaNejYdS8FVLVp9Ss3K1qAVk5de6F8s3HnVbvA
Timeout and Retry Settings
Request Timeout
Maximum time to wait for an API response:
config . timeout = 10_000 // 10 seconds
Increase for slow networks:
config . timeout = 30_000 // 30 seconds
Timeout is in milliseconds . Default is 10,000ms (10 seconds).
Retry Attempts
Number of retry attempts before failing:
config . retry = 8 // Try up to 8 times
With 8 retries and multiple nodes, hive-tx will:
Try first node
On failure, try second node
Continue through all nodes
Repeat up to 8 total attempts
Reduce retries for faster failure:
config . retry = 3 // Fail faster
Complete Configuration
Here’s the full default configuration:
export const config = {
nodes: [
'https://api.hive.blog' ,
'https://api.deathwing.me' ,
'https://api.openhive.network' ,
'https://rpc.mahdiyari.info' ,
'https://techcoderx.com' ,
'https://hiveapi.actifit.io' ,
'https://api.c0ff33a.uk'
],
restNodes: [
'https://api.hive.blog' ,
'https://rpc.mahdiyari.info' ,
'https://techcoderx.com' ,
'https://hiveapi.actifit.io' ,
'https://api.c0ff33a.uk'
],
chain_id: 'beeab0de00000000000000000000000000000000000000000000000000000000' ,
address_prefix: 'STM' ,
timeout: 10_000 ,
retry: 8
}
Use Cases
Custom Node Setup
Use your own Hive node infrastructure:
import { config } from 'hive-tx'
// Production setup with your nodes
config . nodes = [
'https://hive-1.mycompany.com' ,
'https://hive-2.mycompany.com' ,
'https://hive-3.mycompany.com'
]
config . restNodes = [
'https://hive-rest.mycompany.com'
]
config . timeout = 15_000
config . retry = 5
Testnet Configuration
Switch to Hive testnet:
import { config } from 'hive-tx'
// Testnet settings
config . nodes = [
'https://testnet.openhive.network'
]
config . restNodes = [
'https://testnet.openhive.network'
]
config . chain_id = '18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e'
config . address_prefix = 'TST'
Development Mode
Faster failures during development:
import { config } from 'hive-tx'
// Quick failures for development
config . timeout = 5_000 // 5 second timeout
config . retry = 2 // Only retry once
// Use only fast nodes
config . nodes = [
'https://api.hive.blog' ,
'https://api.deathwing.me'
]
Production Reliability
Maximize reliability for production:
import { config } from 'hive-tx'
// Production reliability
config . timeout = 20_000 // Longer timeout
config . retry = 12 // More retries
// All available nodes
config . nodes = [
'https://api.hive.blog' ,
'https://api.deathwing.me' ,
'https://api.openhive.network' ,
'https://rpc.mahdiyari.info' ,
'https://techcoderx.com' ,
'https://hiveapi.actifit.io' ,
'https://api.c0ff33a.uk' ,
'https://my-backup.example.com' // Your backup node
]
Node Failover
hive-tx automatically handles node failures:
Request sent to first node in config.nodes
Timeout or error occurs
Retry with next node in the list
Continue until success or all retries exhausted
// Example failover sequence:
// 1. Try api.hive.blog
// 2. Timeout → Try api.deathwing.me
// 3. Error → Try api.openhive.network
// 4. Success → Return result
Failover is automatic and transparent. Your code doesn’t need to handle node failures - hive-tx does it for you.
Environment-Based Configuration
Use environment variables to configure nodes:
import { config } from 'hive-tx'
// Configure from environment
if ( process . env . HIVE_NODES ) {
config . nodes = process . env . HIVE_NODES . split ( ',' )
}
if ( process . env . HIVE_CHAIN_ID ) {
config . chain_id = process . env . HIVE_CHAIN_ID
}
if ( process . env . HIVE_TIMEOUT ) {
config . timeout = parseInt ( process . env . HIVE_TIMEOUT )
}
Then in your .env file:
HIVE_NODES = https://node1.example.com,https://node2.example.com
HIVE_CHAIN_ID = beeab0de00000000000000000000000000000000000000000000000000000000
HIVE_TIMEOUT = 15000
TypeScript Types
The configuration object has full TypeScript support:
interface Config {
nodes : string []
restNodes : string []
chain_id : string
address_prefix : string
timeout : number
retry : number
}
TypeScript will warn if you set invalid values:
config . timeout = '5000' // ❌ Error: Type 'string' is not assignable to type 'number'
config . timeout = 5000 // ✅ Correct
Best Practices
Use at least 3 nodes for reliability
Include geographically diverse nodes
Test nodes before adding to production config
Monitor node performance and remove slow/unreliable nodes
Use shorter timeouts (5-10s) for interactive apps
Use longer timeouts (15-30s) for background tasks
Consider network conditions of your users
Balance between responsiveness and reliability
More retries = higher reliability but slower failures
Fewer retries = faster failures but less resilient
Consider exponential backoff for custom retry logic
Log retry attempts for debugging
Never mix mainnet and testnet chain IDs
Verify chain ID matches your target network
Use environment variables for different environments
Document which network your app targets
Troubleshooting
All Nodes Failing
// Increase timeout and retries
config . timeout = 30_000
config . retry = 15
// Add more nodes
config . nodes . push ( 'https://another-node.com' )
Slow Response Times
// Use only fast nodes
config . nodes = [
'https://api.hive.blog' ,
'https://api.deathwing.me'
]
// Reduce timeout for faster failures
config . timeout = 5_000
Wrong Network Errors
// Verify chain ID matches network
console . log ( config . chain_id )
// Mainnet:
config . chain_id = 'beeab0de00000000000000000000000000000000000000000000000000000000'
// Testnet:
config . chain_id = '18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e'
Next Steps
Transactions Create and broadcast transactions
API Methods Call Hive API methods
API Calls Guide Learn how to make API calls
Transaction Guide Create and broadcast transactions