Skip to main content

Try it Live

Run Authorization examples in the interactive playground

Utilities

Helper functions for authorization formatting and comparison.

format

Format authorization to human-readable string.
Parameters:
  • auth: Authorization (signed or unsigned) to format
Returns: Human-readable string representation

Usage

Signed Authorization:
Unsigned Authorization:

Format Details

Signed format:
Unsigned format:
Address formatting: Shortened to 0x{first4}...{last4}

Examples

Use Cases

Logging:
Debugging:
Display:

equals

Check if two authorizations are equal.
Parameters:
  • auth1: First authorization
  • auth2: Second authorization
Returns: true if all fields are equal, false otherwise Comparison: Compares all fields:
  • chainId
  • address (byte-by-byte)
  • nonce
  • yParity
  • r
  • s

Usage

Implementation Details

Address Comparison: Byte-by-byte comparison:
Field Comparison:

Examples

Exact match:
Different chainId:
Different address:
Different signature:

Common Patterns

Deduplication

Remove duplicate authorizations:

Authorization Set

Track unique authorizations:

Logging Helper

Create logging helper:

Comparison Helper

Compare and report differences:

Format for Display

Create display-friendly format:

Batch Formatting

Format multiple authorizations:

Find Duplicates

Find all duplicates in list:

Performance

format

O(1) - Constant time string construction Cost:
  • Address shortening: O(40) = O(1)
  • String concatenation: O(1)
  • Number to hex conversion: O(log n) for bigint

equals

O(1) - Constant time comparison Cost:
  • 5 bigint comparisons: O(1) each
  • 1 number comparison: O(1)
  • Address comparison: O(20) = O(1)
Total: O(1)

Optimization Tips

  1. Cache formatted strings if formatting same auth repeatedly
  2. Use equals for deduplication instead of string comparison
  3. Batch format operations when possible

Testing

Test format

Test equals

See Also