Documentation Index Fetch the complete documentation index at: https://mintlify.com/openhive-network/wax/llms.txt
Use this file to discover all available pages before exploring further.
The IHiveChainInterface extends IWaxBaseInterface with online chain access capabilities, including API calls, transaction broadcasting, and enhanced transaction creation with automatic TAPOS.
Inheritance
IHiveChainInterface extends all methods and properties from IWaxBaseInterface .
Properties
api
Access to all Hive blockchain APIs through typed interfaces.
readonly api : {
account_by_key_api : JsonRpcApiData < 'account_by_key_api' > ;
block_api : JsonRpcApiData < 'block_api' > ;
database_api : JsonRpcApiData < 'database_api' > ;
network_broadcast_api : JsonRpcApiData < 'network_broadcast_api' > ;
rc_api : JsonRpcApiData < 'rc_api' > ;
};
Available APIs
Account lookup by public key Get account names associated with public keys
Block data retrieval Get a specific block by number
Get block header information
Core database queries get_dynamic_global_properties
Get current chain state
Verify transaction authority
Transaction broadcasting Broadcast a signed transaction to the network
Resource credit queries Find resource credit account information
restApi
Access to REST API endpoints for hafbe (Hive Application Framework Backend).
readonly restApi : TDefaultRestApi ;
Configuration
Setting endpoint URLs
You can customize endpoint URLs per API or globally:
// Set endpoint for specific API
chain . api . database_api . endpointUrl = "https://custom-node.example.com" ;
// Reset to default
chain . api . database_api . endpointUrl = undefined ;
// Set REST API endpoint
chain . restApi . endpointUrl = "https://custom-hafbe.example.com" ;
Enhanced transaction methods
createTransaction
Creates a transaction with automatic TAPOS using current head block.
async createTransaction ( expirationTime ?: TTimestamp ): Promise < IOnlineTransaction > ;
Optional expiration time. Can be:
Date object
Unix timestamp (number)
ISO 8601 string
Relative time: "+10s", "+30m", "+1h"
Defaults to "+1m"
Promise<IOnlineTransaction>
Promise<IOnlineTransaction>
Promise that resolves to an online transaction with verification capabilities
Usage example
// Create transaction with automatic TAPOS
const tx = await chain . createTransaction ( "+5m" );
// Add operations
tx . pushOperation ({
vote: {
voter: "alice" ,
author: "bob" ,
permlink: "example-post" ,
weight: 10000
}
});
// Sign with signature provider
const signature = await signer . signTransaction ( tx . sigDigest );
tx . addSignature ( signature );
// Broadcast
await chain . api . network_broadcast_api . broadcast_transaction ({
trx: tx . toApiJson ()
});
API usage examples
Get dynamic global properties
const dgpo = await chain . api . database_api . get_dynamic_global_properties ({});
console . log ( 'Head block:' , dgpo . head_block_number );
console . log ( 'Head block ID:' , dgpo . head_block_id );
console . log ( 'Time:' , dgpo . time );
console . log ( 'Current witness:' , dgpo . current_witness );
Find accounts
const result = await chain . api . database_api . find_accounts ({
accounts: [ "alice" , "bob" ]
});
for ( const account of result . accounts ) {
console . log ( `Account: ${ account . name } ` );
console . log ( `Balance: ${ account . balance . amount } ` );
console . log ( `Vesting shares: ${ account . vesting_shares . amount } ` );
}
Get block
const block = await chain . api . block_api . get_block ({
block_num: 12345678
});
console . log ( 'Block ID:' , block . block . block_id );
console . log ( 'Timestamp:' , block . block . timestamp );
console . log ( 'Transactions:' , block . block . transactions . length );
Get key references
const result = await chain . api . account_by_key_api . get_key_references ({
keys: [ "STM7Q2rLBqzPzFeteQZewv9Lu3NLE69fZoLeL6YK59t7UmssCBNTU" ]
});
console . log ( 'Accounts:' , result . accounts );
Find RC accounts
const result = await chain . api . rc_api . find_rc_accounts ({
accounts: [ "alice" ]
});
for ( const account of result . rc_accounts ) {
console . log ( `Account: ${ account . account } ` );
console . log ( `Max RC: ${ account . max_rc } ` );
console . log ( `RC Manabar:` , account . rc_manabar );
}
Broadcast transaction
// Create and sign transaction
const tx = await chain . createTransaction ();
tx . pushOperation ({
vote: {
voter: "alice" ,
author: "bob" ,
permlink: "example-post" ,
weight: 10000
}
});
const signature = await signer . signTransaction ( tx . sigDigest );
tx . addSignature ( signature );
// Broadcast to network
try {
await chain . api . network_broadcast_api . broadcast_transaction ({
trx: tx . toApiJson ()
});
console . log ( 'Transaction broadcasted successfully' );
} catch ( error ) {
console . error ( 'Broadcast failed:' , error );
}
Online transaction features
IOnlineTransaction
The IOnlineTransaction interface extends ITransaction with additional verification methods.
Performs transaction checks that require chain API access.
async performOnChainVerification (): Promise < void > ;
Supported checks:
Private key leakage prevention
Authority validation
generateAuthorityVerificationTrace
Generates authority verification trace for the transaction.
async generateAuthorityVerificationTrace (
useLegacySerialization ?: boolean ,
externalTx ?: ITransaction
): Promise < IVerifyAuthorityTrace > ;
Optional flag to use legacy (pre-HF26) serialization
Optional external transaction for verification
Promise<IVerifyAuthorityTrace>
Promise<IVerifyAuthorityTrace>
Authority verification trace data
Usage example
// Create and sign transaction
const tx = await chain . createTransaction ();
tx . pushOperation ({
transfer: {
from: "alice" ,
to: "bob" ,
amount: chain . hiveCoins ( 10 ),
memo: "Test transfer"
}
});
const signature = await signer . signTransaction ( tx . sigDigest );
tx . addSignature ( signature );
// Verify on-chain (checks for private key leakage)
try {
await tx . performOnChainVerification ();
console . log ( 'Transaction verified successfully' );
} catch ( error ) {
console . error ( 'Verification failed:' , error );
}
// Generate authority trace
const trace = await tx . generateAuthorityVerificationTrace ();
console . log ( 'Authority trace:' , trace );
API customization
Extending APIs
You can extend the API with custom endpoints:
// Add custom endpoint
chain . api . custom_api = {
my_method : async ( params ) => {
const response = await fetch ( ` ${ chain . api . endpointUrl } /custom_api.my_method` , {
method: 'POST' ,
body: JSON . stringify ( params )
});
return response . json ();
}
};
Setting API timeout
API timeout is configured during chain creation:
const chain = await createHiveChain ({
apiTimeout: 5000 // 5 seconds
});
Identify your application with the X-Wax-Api-Caller header:
const chain = await createHiveChain ({
waxApiCaller: "my-awesome-app/1.0.0"
});
TypeScript types
type TTimestamp = Date | number | string ;
interface IOnlineTransaction extends ITransactionBase {
performOnChainVerification () : Promise < void >;
generateAuthorityVerificationTrace (
useLegacySerialization ?: boolean ,
externalTx ?: ITransaction
) : Promise < IVerifyAuthorityTrace >;
}
interface IWaxOptionsChain extends IWaxOptions {
apiEndpoint : string ;
restApiEndpoint : string ;
waxApiCaller ?: string ;
apiTimeout : number ;
}
Error handling
try {
const result = await chain . api . database_api . find_accounts ({
accounts: [ "nonexistent" ]
});
} catch ( error ) {
if ( error instanceof WaxError ) {
console . error ( 'WAX error:' , error . message );
} else {
console . error ( 'Unexpected error:' , error );
}
}
See also