Try it Live
Run Transaction examples in the interactive playground
Transaction Utilities
Utility methods for working with transactions across all types.format
Format transaction to human-readable string.Usage
getGasPrice
Get transaction gas price (handles all types).Parameters
tx: Any- Any transaction typebaseFee?: bigint- Required for EIP-1559+ transactions
Returns
bigint - Gas price in wei
Throws
Error("baseFee required for EIP-1559+ transactions")- If baseFee missing for dynamic fee transactions
Usage
hasAccessList
Check if transaction supports access lists.Returns
true- For EIP-2930, EIP-1559, EIP-4844, EIP-7702false- For Legacy
Usage
getAccessList
Get transaction access list.Returns
AccessList- Transaction access list[]- Empty array for Legacy transactions
Usage
getChainId
Get transaction chain ID.Returns
bigint- Chain IDnull- For pre-EIP-155 Legacy transactions
Usage
isSigned
Check if transaction has a signature.Returns
true- If transaction has non-zero r and sfalse- If r or s is all zeros
Usage
assertSigned
Assert transaction is signed (throws if not).Throws
Error("Transaction is not signed")- If r or s is all zeros
Usage
Usage Patterns
Transaction Cost Calculation
Replay Protection Check
Access List Extraction
Transaction Display
Signature Validation
Transaction Pool Entry
Performance Tips
- Cache getSender results - ECDSA recovery is expensive
- Batch getGasPrice calls - Reuse baseFee for multiple transactions
- Check isSigned before getSender - Avoid unnecessary recovery attempts
- Use hasAccessList before getAccessList - Skip unnecessary checks

