Skip to main content

Try it Live

Run Transaction examples in the interactive playground

format

Format transaction for human-readable display.

Format Components

The formatted output includes:
  1. Transaction Type - Legacy, EIP-2930, EIP-1559, EIP-4844, or EIP-7702
  2. Operation - Transfer or contract creation
  3. Recipient - Address (shortened) or “contract creation”
  4. Value - ETH amount if non-zero
  5. Nonce - Transaction sequence number
  6. Data - Byte length if present

Format Patterns

Standard Transfer

Example: "EIP-1559 tx to 0x742d35Cc..., value: 1 ETH, nonce: 5"

Contract Creation

Example: "EIP-1559 contract creation, data: 1234 bytes, nonce: 0"

Zero Value Transfer

Example: "Legacy tx to 0x..., nonce: 10"

With Data

Example: "EIP-1559 tx to 0x..., value: 0.1 ETH, data: 68 bytes, nonce: 2"

Usage Patterns

Logging

User Notifications

Debug Output

Transaction History

Error Messages

Batch Processing

Custom Formatting

For more control, access fields directly:

Comparison with toString

Unlike JSON.stringify, format() provides human-readable output:

See Also

References