Signing with a Single Key
1
Create and prepare your transaction
2
Load your private key
3
Sign the transaction
sign() method returns the signed transaction object.4
Broadcast to the network
Understanding Key Types
Different operations require different key authorities:Broadcasting Options
Thebroadcast() 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
within_irreversible_block- Successfully included and irreversibleexpired_irreversible- Transaction expired before inclusiontoo_old- Transaction is too old to be included
Checking Transaction Status
You can manually check transaction status after broadcasting:unknown- Not found (not yet processed)within_mempool- Waiting in mempoolwithin_reversible_block- Included but reversiblewithin_irreversible_block- Included and irreversibleexpired_reversible- Expired (was in reversible block)expired_irreversible- Expired (confirmed)too_old- Transaction too old to track
Error Handling
Handling Broadcast Errors
Common Errors
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:Complete Example
Here’s a complete example with error handling and status checking:Next Steps
- Learn about Key Management best practices
- Set up Multi-signature transactions
- Explore API Calls for querying blockchain data