ParentToChildMessageGasEstimator

class arbitrum_py.message.parent_to_child_message_gas_estimator.PercentIncrease(*args, **kwargs)[source]

Bases: dict

Configuration for percentage-based increases in gas parameters.

Variables:
  • base – If provided, will override the estimated base value

  • percentIncrease – How much to increase the base by (in percentage)

base: Optional[NewType()(Wei, int)]
percentIncrease: Optional[int]
class arbitrum_py.message.parent_to_child_message_gas_estimator.GasLimitOverride(*args, **kwargs)[source]

Bases: dict

Extended configuration for gas limit estimation.

Variables:
  • base – If provided, will override the estimated base gas limit

  • percentIncrease – How much to increase the base by (in percentage)

  • min – Minimum gas limit to enforce

min: Optional[NewType()(Wei, int)]
base: Optional[NewType()(Wei, int)]
percentIncrease: Optional[int]
class arbitrum_py.message.parent_to_child_message_gas_estimator.GasOverrides(*args, **kwargs)[source]

Bases: dict

Configuration for overriding gas estimation parameters.

Variables:
  • gasLimit – Override settings for gas limit estimation

  • maxSubmissionFee – Override settings for max submission fee

  • maxFeePerGas – Override settings for max fee per gas

  • deposit – Override settings for deposit amount

gasLimit: Optional[GasLimitOverride]
maxSubmissionFee: Optional[PercentIncrease]
maxFeePerGas: Optional[PercentIncrease]
deposit: Optional[Dict[str, NewType()(Wei, int)]]
class arbitrum_py.message.parent_to_child_message_gas_estimator.ParentToChildMessageGasEstimator(child_provider)[source]

Bases: object

Gas estimator for parent-to-child messages in Arbitrum.

This class provides functionality to estimate gas parameters for sending retryable transactions from the parent chain to the child chain. It handles:

  • Gas limit estimation

  • Max fee per gas estimation

  • Submission cost estimation

  • Deposit amount calculation

The estimator includes safety margins to account for price fluctuations and ensures transactions have sufficient gas for execution.

__init__(child_provider)[source]

Initialize the gas estimator.

Parameters:

child_provider (Web3) – Web3 provider connected to the child chain

percent_increase(num, increase)[source]

Increase a number by a percentage.

Parameters:
  • num (NewType()(Wei, int)) – Base number to increase

  • increase (int) – Percentage to increase by

Return type:

NewType()(Wei, int)

Returns:

Original number increased by the specified percentage

apply_submission_price_defaults(max_submission_fee_options=None)[source]

Apply default values for submission price parameters.

Parameters:

max_submission_fee_options (Optional[PercentIncrease]) – Optional overrides for submission fee calculation

Return type:

PercentIncrease

Returns:

Dictionary with base and percentIncrease values, using defaults where not specified

apply_max_fee_per_gas_defaults(max_fee_per_gas_options=None)[source]

Apply default values for max fee per gas parameters.

Parameters:

max_fee_per_gas_options (Optional[PercentIncrease]) – Optional overrides for max fee per gas calculation

Return type:

PercentIncrease

Returns:

Dictionary with base and percentIncrease values, using defaults where not specified

apply_gas_limit_defaults(gas_limit_defaults=None)[source]

Apply default values for gas limit parameters.

Parameters:

gas_limit_defaults (Optional[GasLimitOverride]) – Optional overrides for gas limit calculation

Return type:

GasLimitOverride

Returns:

Dictionary with base, percentIncrease, and min values, using defaults where not specified

estimate_submission_fee(parent_provider, parent_base_fee, call_data_size, options=None)[source]

Estimate the submission fee for a retryable ticket.

This method calculates the fee required to submit a new retryable transaction with the given call data size. The fee is used to cover the cost of storing the retryable ticket on the child chain.

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

  • parent_base_fee (NewType()(Wei, int)) – Current base fee on the parent chain

  • call_data_size (int) – Size of the call data in bytes

  • options (Optional[PercentIncrease]) – Optional overrides for fee calculation

Return type:

NewType()(Wei, int)

Returns:

Estimated submission fee in wei

Example

>>> estimator = ParentToChildMessageGasEstimator(child_provider)
>>> fee = estimator.estimate_submission_fee(
...     parent_provider,
...     Wei(1000000000),  # 1 gwei
...     100,  # 100 bytes of call data
... )
estimate_retryable_ticket_gas_limit(retryable_data, sender_deposit=None)[source]

Estimate the gas limit required for a retryable ticket.

This method estimates the amount of gas needed on the child chain to create and execute a retryable transaction. It accounts for both the gas needed to create the ticket and the gas needed for the actual execution.

Parameters:
  • retryable_data (Dict[str, Any]) – Dictionary containing the retryable transaction parameters

  • sender_deposit (Optional[NewType()(Wei, int)]) – Optional deposit amount from the sender

Return type:

NewType()(Wei, int)

Returns:

Estimated gas limit in wei

Raises:

ArbSdkError – If the gas estimation fails

estimate_max_fee_per_gas(options=None)[source]

Estimate the max fee per gas for a retryable ticket.

This method calculates the maximum fee per gas that can be paid for a retryable transaction. It includes a safety margin to account for price fluctuations.

Parameters:

options (Optional[PercentIncrease]) – Optional overrides for max fee per gas calculation

Return type:

NewType()(Wei, int)

Returns:

Estimated max fee per gas in wei

static is_valid(estimates, re_estimates)[source]

Validate that the estimates remain safe if compared to fresh re-estimates from chain.

Parameters:
  • estimates (Dict[str, NewType()(Wei, int)]) – Original estimates

  • re_estimates (Dict[str, NewType()(Wei, int)]) – Re-estimated values

Return type:

bool

Returns:

True if the original estimates are still safe, False otherwise

estimate_all(retryable_estimate_data, parent_base_fee, parent_provider, options=None)[source]

Estimate all gas parameters for a retryable ticket.

This method estimates the gas limit, max fee per gas, submission cost, and deposit amount required for a retryable transaction.

Parameters:
  • retryable_estimate_data (Dict[str, Any]) – Dictionary containing the retryable transaction parameters

  • parent_base_fee (NewType()(Wei, int)) – Current base fee on the parent chain

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

  • options (Optional[GasOverrides]) – Optional overrides for gas estimation parameters

Return type:

Dict[str, NewType()(Wei, int)]

Returns:

Dictionary containing the estimated gas parameters

populate_function_params(data_func, parent_provider, gas_overrides=None)[source]

Populate function parameters for a retryable ticket.

This method generates the necessary parameters for a retryable transaction, including the gas limit, max fee per gas, submission cost, and deposit amount.

Parameters:
  • data_func – Function that generates the transaction data

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

  • gas_overrides (Optional[GasOverrides]) – Optional overrides for gas estimation parameters

Returns:

Dictionary containing the populated function parameters