Skip to main content
Transactions are the core building blocks for interacting with the Hive blockchain. This guide shows you how to create transactions with different types of operations.

Basic Transaction Flow

1

Import the Transaction class

2

Create a new transaction

You can optionally set a custom expiration time (in milliseconds):
Default expiration is 60 seconds (60,000 ms). Maximum is 24 hours (86,400,000 ms).
3

Add operations to the transaction

Use addOperation() to add operations. This method automatically creates the transaction structure on first call:
4

Sign and broadcast

Transfer Operation

Send HIVE or HBD tokens between accounts:
For transfers, you need the account’s active key.

Vote Operation

Upvote or downvote content:
Vote weight ranges from -10000 (100% downvote) to 10000 (100% upvote). Use posting key for voting.

Comment Operation

Create posts and comments:
Create a comment (reply):

Custom JSON Operation

Execute custom operations for apps and games:

Delegate Vesting Shares

Delegate HIVE Power to another account:
Delegation amounts must be in VESTS, not HIVE Power. Use conversion APIs to calculate VESTS from HP.

Multiple Operations in One Transaction

You can add multiple operations to a single transaction:

Transaction Expiration

Control when your transaction expires:
Transactions that haven’t been included in a block when they expire will be dropped from the mempool.

Error Handling

Always wrap transaction creation and broadcasting in try-catch blocks:

Common Errors

Missing Required Authority: Ensure you’re using the correct key type (posting, active, or owner) for your operation.
Insufficient Funds: Check account balance before transferring or delegating.
Invalid Operation Data: Verify all required fields are present and formatted correctly.

Next Steps