Skip to main content
After creating a transaction with operations, you need to sign it with the appropriate private key(s) and broadcast it to the Hive network.

Signing with a Single Key

1

Create and prepare your transaction

2

Load your private key

3

Sign the transaction

The sign() method returns the signed transaction object.
4

Broadcast to the network

Understanding Key Types

Different operations require different key authorities:
Always use the minimum required key authority. Never use owner keys for daily operations.

Broadcasting Options

The broadcast() method accepts a checkStatus parameter:

Quick Broadcast (Default)

Quick broadcast returns immediately but doesn’t guarantee the transaction will be included in a block. The transaction could still expire in the mempool.

Confirmed Broadcast

Possible status values:
  • within_irreversible_block - Successfully included and irreversible
  • expired_irreversible - Transaction expired before inclusion
  • too_old - Transaction is too old to be included
Use confirmed broadcast for critical operations where you need to ensure the transaction was included.

Checking Transaction Status

You can manually check transaction status after broadcasting:
Possible status values:
  • unknown - Not found (not yet processed)
  • within_mempool - Waiting in mempool
  • within_reversible_block - Included but reversible
  • within_irreversible_block - Included and irreversible
  • expired_reversible - Expired (was in reversible block)
  • expired_irreversible - Expired (confirmed)
  • too_old - Transaction too old to track

Error Handling

Handling Broadcast Errors

Common Errors

Missing signatures: Call .sign(key) before broadcasting.
Wrong key authority: Make sure you’re using the correct key type for the operation.
Insufficient funds: Check balance before broadcasting financial operations.

Transaction Digest

Get the transaction hash and ID before broadcasting:
The digest is a SHA256 hash used for signing. The transaction ID is derived from this hash.

Duplicate Transaction Handling

The library automatically handles duplicate transaction errors:
From Transaction.ts:106-124:

Complete Example

Here’s a complete example with error handling and status checking:

Next Steps