Skip to main content

What is a transaction

A transaction is a signed, atomic unit of work that you submit to the Hive blockchain. Each transaction contains one or more operations that modify the blockchain state.
All operations within a transaction either succeed together or fail together. This ensures data consistency across the blockchain.

Transaction lifecycle

Creating transactions

You create transactions using the chain instance or foundation instance, depending on whether you need online or offline functionality.

Transaction options

You can customize transaction creation with several options:
string
Block ID for TAPOS (Transaction as Proof of Stake) reference
string | timedelta
default:"+1m"
When the transaction expires (e.g., "+1m", "+5m", "+1h")
string
default:"mainnet"
Chain ID for the target blockchain (mainnet, testnet, etc.)
Date | HiveDateTime
Reference time for expiration calculation (useful for testnets)

TAPOS (Transaction as Proof of Stake)

TAPOS ensures your transaction references a recent block, preventing replay attacks across different blockchain forks.

How TAPOS works

Every transaction includes:
  • ref_block_num: Lower 16 bits of the referenced block number
  • ref_block_prefix: First 32 bits of the referenced block ID
These values are automatically calculated from the block ID:
ts/wasm/lib/detailed/transaction.ts

Building transactions

You build transactions by adding operations using the pushOperation() method:

Complex operations

WAX provides high-level operation builders for complex operations:

Transaction structure

At the protocol level, a transaction has the following structure:

Example transaction

Validation

Before signing, you can (and should) validate your transaction:
Validation is automatically performed when you sign a transaction, but it’s good practice to validate early to catch errors.

What validation checks

The validation process verifies:
  • Operation structure matches protocol definitions
  • Required fields are present
  • Field values are within allowed ranges
  • Account names follow Hive naming rules
  • Assets have correct format and precision
  • Custom JSON is valid

Transaction properties

Once you build a transaction, you can access various properties:

Transaction ID

Signature digest

Impacted accounts

Required authorities

Transaction serialization

You can serialize transactions to different formats:

JSON API format

Binary format

Legacy format

Loading existing transactions

You can load and work with existing transactions:

Expiration handling

Transactions have an expiration time to prevent replay attacks:

Default expiration

Expiration format

The expiration is stored as an ISO 8601 timestamp without milliseconds:
Once a transaction expires, it cannot be broadcast. Make sure to sign and broadcast before expiration.

Implementation details

The transaction implementation resides in:
  • TypeScript: ts/wasm/lib/detailed/transaction.ts:48
  • Python: python/wax/_private/transaction.py:51
  • C++ Core: core/foundation.cpp (handle management)

Transaction handle

Internally, both implementations maintain a handle to the C++ transaction object:
ts/wasm/lib/detailed/transaction.ts

Next steps

Operations

Learn about operations and protocol buffers

Signing

Understand how to sign transactions

Broadcasting

Learn how to broadcast transactions

API Reference

Explore the complete API