ChildToParentMessageClassic

class arbitrum_py.message.child_to_parent_message_classic.MessageBatchProofInfo(proof, path, l2_sender, l1_dest, l2_block, l1_block, timestamp, amount, calldata_for_l1)[source]

Bases: object

Merkle proof info for verifying a message in the outbox entry on the parent chain.

This class contains all the necessary information to verify and execute a message that was sent from a child chain to its parent chain. The proof information is used to validate the message’s inclusion in the outbox entry.

Variables:
  • proof – Merkle proof of message inclusion in outbox entry

  • path – Merkle path to message

  • l2_sender – Sender of original message (caller of ArbSys.sendTxToL1)

  • l1_dest – Destination address for L1 contract call

  • l2_block – L2 block number at which sendTxToL1 call was made

  • l1_block – L1 block number at which sendTxToL1 call was made

  • timestamp – L2 Timestamp at which sendTxToL1 call was made

  • amount – Value in L1 message in wei

  • calldata_for_l1 – ABI-encoded L1 message data

__init__(proof, path, l2_sender, l1_dest, l2_block, l1_block, timestamp, amount, calldata_for_l1)[source]

Initialize a message batch proof info object.

Parameters:
  • proof (List[str]) – Merkle proof of message inclusion in outbox entry

  • path (int) – Merkle path to message

  • l2_sender (str) – Sender of original message (caller of ArbSys.sendTxToL1)

  • l1_dest (str) – Destination address for L1 contract call

  • l2_block (int) – L2 block number at which sendTxToL1 call was made

  • l1_block (int) – L1 block number at which sendTxToL1 call was made

  • timestamp (int) – L2 Timestamp at which sendTxToL1 call was made

  • amount (int) – Value in L1 message in wei

  • calldata_for_l1 (NewType()(HexStr, str)) – ABI-encoded L1 message data

class arbitrum_py.message.child_to_parent_message_classic.ChildToParentMessageClassic(batch_number, index_in_batch)[source]

Bases: object

Base class for Child-to-Parent messages on Arbitrum Classic networks.

This class provides core functionality for handling messages sent from a child chain to its parent chain in the Arbitrum Classic protocol. It supports both reading and writing operations through its subclasses.

The class manages message batches and their indices, providing methods to track and verify message status across both chains.

Variables:
  • batch_number – The number of the batch this message is part of

  • index_in_batch – The index of this message in the batch

__init__(batch_number, index_in_batch)[source]

Initialize a Classic Child-to-Parent message handler.

Parameters:
  • batch_number (int) – The number of the batch this message is part of

  • index_in_batch (int) – The index of this message in the batch

static from_batch_number(parent_signer_or_provider, batch_number, index_in_batch, parent_provider=None)[source]

Create a new Classic Child-to-Parent message handler.

This factory method creates either a reader or writer instance based on whether a signer or provider is supplied. The choice between reader and writer determines the available operations on the message.

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

  • batch_number (int) – The batch number containing the message

  • index_in_batch (int) – The index of the message within the batch

  • parent_provider (Optional[Web3]) – Optional override for the provider

Return type:

Union[ChildToParentMessageReaderClassic, ChildToParentMessageWriterClassic]

Returns:

Either a ChildToParentMessageReaderClassic for read-only operations or ChildToParentMessageWriterClassic for execution operations

static get_child_to_parent_events(child_provider, filter, batch_number=None, destination=None, unique_id=None, index_in_batch=None)[source]

Get Child-to-Parent message events from the child chain.

This method retrieves events that represent messages sent from the child chain to the parent chain within the specified block range. It supports filtering by various parameters to find specific messages.

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 with fromBlock and toBlock

  • batch_number (Optional[int]) – Optional batch number to filter events

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

  • unique_id (Optional[int]) – Optional unique identifier to filter events

  • index_in_batch (Optional[int]) – Optional index in batch to filter events

Return type:

List[Dict[str, Any]]

Returns:

List of event objects containing message information. Each event includes the event args plus transactionHash.

class arbitrum_py.message.child_to_parent_message_classic.ChildToParentMessageReaderClassic(parent_provider, batch_number, index_in_batch)[source]

Bases: ChildToParentMessageClassic

Read-only access for a Classic Child->Parent message.

This class provides methods to read and verify the status of messages sent from a child chain to its parent chain, without the ability to execute them. It is used for monitoring and verifying message status across chains.

Variables:
  • parent_provider – The parent chain provider to query message state

  • batch_number – The batch number for this message (inherited)

  • index_in_batch – The index in the batch for this message (inherited)

  • outbox_address – Cached outbox contract address

  • proof – Cached message proof information

__init__(parent_provider, batch_number, index_in_batch)[source]

Initialize a Classic Child-to-Parent message reader.

Parameters:
  • parent_provider (Web3) – Web3 provider for the parent chain

  • batch_number (int) – The batch number for this message

  • index_in_batch (int) – The index in the batch for this message

get_outbox_address(child_provider, batch_number)[source]

Get the correct outbox contract address for a given batch number.

Classic Arbitrum had multiple outboxes; this method finds the correct outbox by comparing the activation batch number of outboxes. If the next outbox’s activation batch is higher than the current batch number, the current outbox is the correct one.

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

  • batch_number (int) – The batch number to find the outbox for

Return type:

str

Returns:

The address of the correct outbox contract for this batch

Raises:

ArbSdkError – If no valid outbox is found for the batch number

outbox_entry_exists(child_provider)[source]

Check if the outbox entry for this batch exists on the parent chain.

This method verifies whether the outbox entry for this message’s batch has been created on the parent chain, which is necessary before the message can be executed.

Parameters:

child_provider (Web3) – Web3 provider for the child chain

Return type:

bool

Returns:

True if the outbox entry exists, False otherwise

static try_get_proof_static(child_provider, batch_number, index_in_batch)[source]

Try to get the Merkle proof for a specific message.

This static method attempts to retrieve the proof information for a message identified by its batch number and index. The proof is necessary for executing the message on the parent chain.

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

  • batch_number (int) – The batch number containing the message

  • index_in_batch (int) – The index of the message within the batch

Return type:

Optional[MessageBatchProofInfo]

Returns:

MessageBatchProofInfo if the proof exists, None if the batch is not yet created or the proof cannot be retrieved

Raises:

ArbSdkError – If there is an error retrieving the proof that is not related to the batch not existing

try_get_proof(child_provider)[source]

Try to get the proof for this message.

This method attempts to retrieve and cache the proof information for this message. If the proof has already been cached, it returns the cached version.

Parameters:

child_provider (Web3) – Web3 provider for the child chain

Return type:

Optional[MessageBatchProofInfo]

Returns:

MessageBatchProofInfo if the proof exists and can be retrieved, None otherwise

has_executed(child_provider)[source]

Check if this message has been executed on the parent chain.

This method verifies whether the message has already been executed by checking its status on the parent chain. A message can only be executed once.

Parameters:

child_provider (Web3) – Web3 provider for the child chain

Return type:

bool

Returns:

True if the message has been executed, False otherwise

Raises:

ArbSdkError – If there is an error checking the execution status

status(child_provider)[source]

Get the current status of this message.

This method checks the current state of the message and returns its status: - UNCONFIRMED: The outbox entry has not been created yet - CONFIRMED: The outbox entry exists but the message hasn’t been executed - EXECUTED: The message has been successfully executed

Parameters:

child_provider (Web3) – Web3 provider for the child chain

Return type:

ChildToParentMessageStatus

Returns:

ChildToParentMessageStatus indicating the current state of the message

wait_until_outbox_entry_created(child_provider, retry_delay_ms=500)[source]

Wait for the outbox entry to be created on the parent chain.

This method continuously checks for the existence of the outbox entry, waiting between attempts. It will return once the entry is created or if the message has already been executed.

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

  • retry_delay_ms (int) – Milliseconds to wait between checks (default: 500)

Return type:

ChildToParentMessageStatus

Returns:

ChildToParentMessageStatus of either CONFIRMED or EXECUTED

get_first_executable_block(child_provider)[source]

Get the first block number where this message can be executed.

In Classic Arbitrum, messages can be executed in any block after the outbox entry is created, so this method always returns None.

Parameters:

child_provider (Web3) – Web3 provider for the child chain

Return type:

Optional[NewType()(BlockNumber, int)]

Returns:

None, as Classic messages can be executed in any block after confirmation

class arbitrum_py.message.child_to_parent_message_classic.ChildToParentMessageWriterClassic(parent_signer, batch_number, index_in_batch, parent_provider=None)[source]

Bases: ChildToParentMessageReaderClassic

Write access for a Classic Child-to-Parent message.

This class extends ChildToParentMessageReaderClassic to add execution capabilities for messages sent from a child chain to its parent chain. It provides methods to execute messages once they are confirmed on the parent chain.

Variables:
  • parent_signer – The signer to use for executing transactions

  • parent_provider – The parent chain provider (inherited)

  • batch_number – The batch number for this message (inherited)

  • index_in_batch – The index in the batch for this message (inherited)

__init__(parent_signer, batch_number, index_in_batch, parent_provider=None)[source]

Initialize a Classic Child-to-Parent message writer.

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

  • batch_number (int) – The batch number for this message

  • index_in_batch (int) – The index in the batch for this message

  • parent_provider (Optional[Web3]) – Optional override for the parent’s provider

execute(child_provider, overrides=None)[source]

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

This method executes a message that was previously sent from the child chain to the parent chain. The message must be in CONFIRMED status before it can be executed. The execution process involves: 1. Verifying the message status 2. Retrieving the outbox proof 3. Submitting the executeTransaction to the outbox contract

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

  • overrides (Optional[TxParams]) – Optional transaction parameter overrides. Common overrides include: ‘from’, ‘gasLimit’, ‘maxFeePerGas’, ‘maxPriorityFeePerGas’

Return type:

TxReceipt

Returns:

Transaction receipt from the execution transaction

Raises:

ArbSdkError – If the message is not in CONFIRMED status or if the outbox proof cannot be retrieved