Skip to content

feat: add flexible retryable ticket encoding primitive #639

@yahgwai

Description

@yahgwai

Context

The existing ParentToChildMessageCreator.getTicketCreationRequest() requires a child chain provider for gas estimation. This makes it unusable for pre-chain-startup scenarios (like ownership transfer during chain deployment) where the child chain isn't running and gas params must be hardcoded.

Scope

New function: encodeRetryableTicket

  • Accepts target address, calldata, l2CallValue, refund addresses
  • Gas params (gasLimit, maxFeePerGas) provided directly -- no child chain estimation required
  • Calculates maxSubmissionCost from parent chain via Inbox.calculateRetryableSubmissionFee() (or accepts it pre-calculated)
  • Calculates deposit: maxSubmissionCost + (gasLimit * maxFeePerGas) + l2CallValue
  • Handles ETH vs ERC20 native token encoding differences (extra tokenTotalFeeAmount arg)
  • Returns { data: encodedCalldata, deposit, maxSubmissionCost }
  • Does NOT prepare a transaction request -- just encoding and math

Refactor: getTicketCreationRequest

  • Refactor to use encodeRetryableTicket internally after estimating gas params
  • No behavior change, just deduplication

New function (optional): encodeSendL2Message

  • Takes a signed child-chain transaction
  • Prepends the message type byte (0x04 for signed tx)
  • Returns encoded calldata for Inbox.sendL2Message
  • Simple utility used in the same ownership transfer flow

Out of scope

  • Viem support (handled in arbitrum-chain-sdk)
  • Schema definitions
  • Example scripts

Motivation

This is needed to support a transferOwnership scripting workflow in arbitrum-chain-sdk, where retryable tickets must be constructed for a child chain that hasn't started producing blocks yet. The encoding primitive is also generally useful for any cross-chain operation where gas params are known in advance.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions