Skip to content

Conversation

@cliff0412
Copy link

Add X-Prefixed Address Support and Enhanced SDK for X Layer

Summary

This PR introduces support for X-prefixed addresses in the Reth SDK, allowing users to input addresses with an optional "X" prefix (e.g., X1234...) while maintaining compatibility with standard Ethereum address formats. The SDK has been refactored to provide reusable functions for blockchain interactions, and a comprehensive CLI tool has been implemented.

Key Features

1. XAddress Type

  • New XAddress type that accepts addresses with optional "X" prefix
  • Automatically strips "X" prefix and normalizes to standard 0x format for chain operations
  • Supports multiple input formats: X1234..., 0x1234..., or 1234...

2. Enhanced Argument Parsing

  • Recursive parsing support for complex Solidity types:
    • Tuples: Nested tuples with X-prefixed addresses at any depth
    • Dynamic Arrays: address[] with comma-separated or bracket-wrapped values
    • Fixed Arrays: address[N] with length validation
  • Automatic X-prefix stripping from addresses in all nested structures

3. CLI Commands (xlayer_cli.rs)

Complete CLI interface with the following commands:

  • transfer - Transfer native assets
  • token-transfer - Transfer ERC20 tokens
  • balance - Query native balance
  • token-balance - Query ERC20 token balance
  • eth-call - Execute arbitrary contract calls with function signature parsing

Changes

Core SDK (crates/sdk/src/lib.rs)

  • Added XAddress struct with FromStr, From<XAddress> for Address, and Display implementations
  • Implemented recursive coerce_value_recursive() for handling nested types

@cliff0412 cliff0412 requested a review from xzav3r November 10, 2025 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants