ChildToParentMessage

class arbitrum_py.message.child_to_parent_message.ChildToParentMessage[source]

Bases: object

Base functionality for Child-to-Parent messages.

This class provides the core functionality for handling messages sent from a child chain to its parent chain in the Arbitrum ecosystem. It supports both Classic and Nitro message formats.

static is_classic(event)[source]

Check if the event is from the Classic format.

Parameters:

event (Dict[str, Any]) – Event data containing transaction information

Return type:

bool

Returns:

True if the event is in Classic format, False if Nitro

static from_event(parent_signer_or_provider, event, parent_provider=None)[source]

Create a message reader or writer based on the provided signer or provider.

Parameters:
  • parent_signer_or_provider (Any) – Signer or provider for the parent chain

  • event (Dict[str, Any]) – Event data containing the Child-to-Parent message information

  • parent_provider (Optional[BaseProvider]) – Optional override provider for the parent chain

Return type:

Union[ChildToParentMessageReader, ChildToParentMessageWriter]

Returns:

ChildToParentMessageWriter if a signer is provided, ChildToParentMessageReader if a provider is provided

static get_child_to_parent_events(child_provider, filter, position=None, destination=None, hash=None, index_in_batch=None)[source]

Get event logs for Child-to-Parent transactions.

This method retrieves events from both Classic and Nitro formats within the specified block range.

Parameters:
  • child_provider (Web3) – Web3 provider for the child chain

  • filter (Dict[str, Union[Literal['latest', 'earliest', 'pending', 'safe', 'finalized'], NewType()(BlockNumber, int), NewType()(Hash32, bytes), NewType()(HexStr, str), HexBytes, int]]) – Block range filter containing fromBlock and toBlock

  • position (Optional[int]) – Position in batch (for Nitro) or batch number (for Classic)

  • destination (Optional[str]) – Destination address to filter events

  • hash (Optional[str]) – Transaction hash to filter events

  • index_in_batch (Optional[int]) – Index in batch (Classic only)

Return type:

List[Dict[str, Any]]

Returns:

List of event logs matching the specified criteria

Raises:

ArbSdkError – If an unrecognized block tag is provided

class arbitrum_py.message.child_to_parent_message.ChildToParentMessageReader(parent_provider, event)[source]

Bases: ChildToParentMessage

Provides read-only access for Child-to-Parent messages.

This class handles reading and querying the status of messages sent from a child chain to its parent chain.

__init__(parent_provider, event)[source]

Initialize a read-only message handler.

Parameters:
  • parent_provider (BaseProvider) – Provider for the parent chain

  • event (Dict[str, Any]) – Event data containing the message information

get_outbox_proof(child_provider)[source]

Get the outbox proof for the message.

Parameters:

child_provider (Web3) – Web3 provider for the child chain

Return type:

Union[Dict[str, Any], List[str], None]

Returns:

Proof information for Classic format, merkle proof for Nitro format, or None if proof is not available

status(child_provider)[source]

Get the current status of the message.

Parameters:

child_provider (Web3) – Web3 provider for the child chain

Return type:

ChildToParentMessageStatus

Returns:

Current status of the Child-to-Parent message

wait_until_ready_to_execute(child_provider, retry_delay=500)[source]

Wait until the message is ready to be executed.

Warning

This operation may take a very long time (1 week+) as outbox entries are only created when the corresponding node is confirmed.

Parameters:
  • child_provider (Web3) – Web3 provider for the child chain

  • retry_delay (int) – Milliseconds to wait between status checks

Return type:

ChildToParentMessageStatus

Returns:

Final message status (either EXECUTED or CONFIRMED)

get_first_executable_block(child_provider)[source]

Get the first block where this message can be executed.

Parameters:

child_provider (Web3) – Web3 provider for the child chain

Return type:

Optional[int]

Returns:

Block number where message becomes executable, or None if already executable or executed

class arbitrum_py.message.child_to_parent_message.ChildToParentMessageWriter(parent_signer, event, parent_provider=None)[source]

Bases: ChildToParentMessageReader

Provides read and write access for Child-to-Parent messages.

This class extends ChildToParentMessageReader to add the ability to execute messages on the parent chain.

__init__(parent_signer, event, parent_provider=None)[source]

Initialize a message handler with write capabilities.

Parameters:
  • parent_signer (Any) – Signer for the parent chain

  • event (Dict[str, Any]) – Event data containing the message information

  • parent_provider (Optional[BaseProvider]) – Optional override provider for the parent chain

execute(child_provider, overrides=None)[source]

Execute the Child-to-Parent message on the parent chain.

Parameters:
  • child_provider (Web3) – Web3 provider for the child chain

  • overrides (Optional[Dict[str, Any]]) – Optional transaction parameter overrides

Return type:

Dict[str, Any]

Returns:

Transaction receipt

Raises:

Exception – If the outbox entry has not been created