Address

class arbitrum_py.data_entities.address.Address(value)[source]

Bases: object

Ethereum/Arbitrum address class with L1/L2 aliasing support.

This class represents an Ethereum/Arbitrum address and provides functionality for handling the L1 <-> L2 address aliasing used by Arbitrum. It ensures addresses are properly checksummed and validates their format.

The aliasing system is used by Arbitrum to prevent address collisions between L1 and L2. When a contract on L1 sends a message to L2, its address is aliased by adding a constant offset. When L2 sends a message back to L1, the address is un-aliased by subtracting the same offset.

Variables:
  • value (ChecksumAddress) – The checksummed Ethereum address

  • ADDRESS_ALIAS_OFFSET_BIG_INT (int) – The numerical offset used for address aliasing

  • ADDRESS_BIT_LENGTH (int) – Number of bits in an Ethereum address (160)

  • ADDRESS_NIBBLE_LENGTH (int) – Number of hex characters needed (40)

ADDRESS_ALIAS_OFFSET_BIG_INT = 97431955772380292505369553133200691419628441873
ADDRESS_BIT_LENGTH = 160
ADDRESS_NIBBLE_LENGTH = 40
__init__(value)[source]

Initialize an Address instance with validation.

Parameters:

value (Union[str, NewType()(ChecksumAddress, NewType()(HexAddress, NewType()(HexStr, str)))]) – An Ethereum address. Can be checksummed or not, but must be valid.

Raises:

ArbSdkError – If the provided address is not a valid Ethereum address.

_alias(address, forward)[source]

Compute address alias by adding or subtracting the alias offset.

Internal helper that performs the actual address aliasing computation. The result is guaranteed to fit within 160 bits through modular arithmetic.

Parameters:
  • address (str) – A hex Ethereum address without ‘0x’ prefix

  • forward (bool) – If True, compute L1->L2 alias (add offset) If False, compute L2->L1 alias (subtract offset)

Return type:

NewType()(ChecksumAddress, NewType()(HexAddress, NewType()(HexStr, str)))

Returns:

The checksummed aliased address

apply_alias()[source]

Compute the L2 alias of this L1 address.

When contracts on L1 send messages to L2, their addresses are aliased by adding ADDRESS_ALIAS_OFFSET to prevent address collisions.

Return type:

Address

Returns:

A new Address instance representing the L2 alias of this address

undo_alias()[source]

Compute the L1 address from this L2 alias.

When contracts on L2 send messages back to L1, aliased addresses are converted back to their original L1 form by subtracting ADDRESS_ALIAS_OFFSET.

Return type:

Address

Returns:

A new Address instance representing the original L1 address

equals(other)[source]

Compare two addresses for equality, ignoring case.

Parameters:

other (Address) – Another Address instance to compare with

Return type:

bool

Returns:

True if the addresses match (case-insensitive), False otherwise

__eq__(other)[source]

Enable == operator for comparing Address instances.

Parameters:

other (object) – Object to compare with this Address

Return type:

bool

Returns:

True if other is an Address with the same value (case-insensitive)

__str__()[source]

Get string representation of the address.

Return type:

str

Returns:

The checksummed address value

__repr__()[source]

Get detailed string representation of the Address instance.

Return type:

str

Returns:

A string showing the class name and checksummed address value