[docs]classArbBlockProps(TypedDict):"""Additional fields for an Arbitrum block beyond standard Ethereum block fields. This class defines the Arbitrum-specific fields that extend a standard Ethereum block. These fields provide information about L2->L1 messages (withdrawals) and L1 block number tracking. Attributes: sendRoot (HexStr): The merkle root of the withdrawals tree sendCount (int): Cumulative number of withdrawals since genesis l1BlockNumber (int): The L1 block number as seen from within this L2 block. This is used for block.number calls within Arbitrum transactions. See: https://developer.offchainlabs.com/docs/time_in_arbitrum """sendRoot:HexStrsendCount:intl1BlockNumber:int
[docs]classArbBlock(Dict[str,Any]):"""An Arbitrum block combining standard Ethereum and Arbitrum-specific fields. This class merges standard Web3 block data (Web3Block) with Arbitrum-specific fields (ArbBlockProps). It provides a complete view of an Arbitrum block including both L1 and L2 relevant information. Inherits all fields from Web3Block (standard Ethereum block fields) plus: - All fields from ArbBlockProps """
[docs]classArbBlockWithTransactions(ArbBlock):"""An Arbitrum block that includes full transaction objects. Similar to ethers.js BlockWithTransactions, this class includes the full transaction objects rather than just transaction hashes. Useful when you need detailed transaction data along with the block data. Attributes: transactions (List[TxData]): List of full transaction objects included in this block """
[docs]def__init__(self,block_data:Dict[str,Any]):super().__init__(block_data)if"transactions"notinself:raiseValueError("Missing transactions field in block data")ifnotisinstance(self["transactions"],list):raiseValueError("Transactions field must be a list")
[docs]classArbTransactionReceipt(Dict[str,Any]):"""An Ethereum transaction receipt with additional Arbitrum-specific fields. This class extends the standard Ethereum transaction receipt with fields that are specific to Arbitrum's L2 execution environment, particularly around L1 block number tracking and L1 computation costs. Attributes: l1BlockNumber (int): The L1 block number that would be used for block.number calls occurring within this transaction. See: https://developer.offchainlabs.com/docs/time_in_arbitrum gasUsedForL1 (int): Amount of gas spent on L1 computation, denominated in L2 gas units transactionHash (Hash32): Hash of the transaction transactionIndex (int): Integer of the transaction's index position in the block blockHash (Hash32): Hash of the block where this transaction was in blockNumber (BlockNumber): Block number where this transaction was in from_ (HexStr): Address of the sender to (Optional[HexStr]): Address of the receiver. null when its a contract creation status (int): Either 1 (success) or 0 (failure) contractAddress (Optional[HexStr]): The contract address created, if the transaction was a contract creation, otherwise null logs (List[LogReceipt]): Array of log objects that this transaction generated """
[docs]def__init__(self,receipt_data:Dict[str,Any]):super().__init__()# Copy standard receipt fieldsforkey,valueinreceipt_data.items():ifkey=="from":self["from_"]=value# Handle Python keywordelse:self[key]=value# Ensure Arbitrum-specific fields are presentifnotall(fieldinselfforfieldin["l1BlockNumber","gasUsedForL1"]):raiseValueError("Missing required Arbitrum transaction receipt fields")