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.- TypeScript
- Python
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 numberref_block_prefix: First 32 bits of the referenced block ID
- TypeScript
- Python
ts/wasm/lib/detailed/transaction.ts
Building transactions
You build transactions by adding operations using thepushOperation() method:
- TypeScript
- Python
Complex operations
WAX provides high-level operation builders for complex operations:- TypeScript
- Python
Transaction structure
At the protocol level, a transaction has the following structure:Example transaction
Validation
Before signing, you can (and should) validate your transaction:- TypeScript
- Python
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
- TypeScript
- Python
Signature digest
- TypeScript
- Python
Impacted accounts
- TypeScript
- Python
Required authorities
- TypeScript
- Python
Transaction serialization
You can serialize transactions to different formats:JSON API format
- TypeScript
- Python
Binary format
- TypeScript
- Python
Legacy format
- TypeScript
- Python
Loading existing transactions
You can load and work with existing transactions:- TypeScript
- Python
Expiration handling
Transactions have an expiration time to prevent replay attacks:Default expiration
- TypeScript
- Python
Expiration format
The expiration is stored as an ISO 8601 timestamp without milliseconds: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:- TypeScript
- Python
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