### Install Nitro Precompile Interfaces Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Install the package using npm or yarn. For Foundry/Hardhat, add it as a dependency and import interfaces directly. ```bash # npm / yarn npm install @arbitrum/nitro-precompile-interfaces yarn add @arbitrum/nitro-precompile-interfaces # Foundry (foundry.toml) # Add the package as a dependency and import with: # import "@arbitrum/nitro-precompile-interfaces/ArbSys.sol"; ``` -------------------------------- ### Get Ticket Info Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Inspect a ticket's status, including its timeout, beneficiary, and minimum lifetime. ```APIDOC ## getTicketInfo ### Description Inspect a ticket's status, returning its expiry timeout, beneficiary address, and minimum lifetime. ### Method View function call to the ArbRetryableTx precompile. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```solidity RETRYABLE.getTimeout(ticketId) RETRYABLE.getBeneficiary(ticketId) RETRYABLE.getLifetime() ``` ### Response #### Success Response - **timeout** (uint256) - The Unix timestamp of the ticket's expiry. - **beneficiary** (address) - The address of the ticket's beneficiary. - **lifetime** (uint256) - The minimum ticket lifetime in seconds. #### Response Example ```json { "timeout": 1678886400, "beneficiary": "0x...", "lifetime": 604800 } ``` ``` -------------------------------- ### ArbMultiGasConstraintsTypes - setupMultiGas Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Sets up a two-constraint multi-gas pricing model for computation and storage growth. This function configures adjustment windows, target rates per second, and backlogs for each resource type. ```APIDOC ## setupMultiGas ### Description Sets up a two-constraint multi-gas pricing model: one for computation, one for storage growth. This function configures the `ArbMultiGasConstraintsTypes.ResourceConstraint` for each resource, including adjustment window duration, target rate per second, and backlog. ### Method External Call ### Parameters None ### Request Example ```solidity // Example usage within a contract: // OWNER.setMultiGasPricingConstraints(constraints); ``` ### Response None (modifies chain state) ``` -------------------------------- ### Get Current Redeemer Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Returns the address of the redeemer for the currently executing retryable transaction, or address(0) if it is not a redeem operation. ```APIDOC ## getCurrentRedeemer ### Description Returns the redeemer of the currently executing retryable transaction. Returns the zero address if the current execution is not a retryable redemption. ### Method View function call to the ArbRetryableTx precompile. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```solidity RETRYABLE.getCurrentRedeemer() ``` ### Response #### Success Response - **address** (address) - The address of the redeemer, or the zero address if not a redeem operation. #### Response Example ```json { "address": "0x..." } ``` ``` -------------------------------- ### Set Up Multi-Gas Pricing Constraints Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Configures a two-constraint multi-gas pricing model for computation and storage growth using ArbOwner. Requires specific weights, adjustment windows, and target rates per second. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@arbitrum/nitro-precompile-interfaces/ArbMultiGasConstraintsTypes.sol"; import "@arbitrum/nitro-precompile-interfaces/ArbOwner.sol"; import "@arbitrum/nitro-precompile-interfaces/ArbGasInfo.sol"; contract MultiGasExample { using ArbMultiGasConstraintsTypes for *; ArbOwner constant OWNER = ArbOwner(0x0000000000000000000000000000000000000070); ArbGasInfo constant GAS_INFO = ArbGasInfo(0x000000000000000000000000000000000000006c); /// @notice Set up a two-constraint multi-gas pricing model: /// one for computation, one for storage growth. function setupMultiGas() external { ArbMultiGasConstraintsTypes.WeightedResource[] memory computeResources = new ArbMultiGasConstraintsTypes.WeightedResource[](1); computeResources[0] = ArbMultiGasConstraintsTypes.WeightedResource({ resource: ArbMultiGasConstraintsTypes.ResourceKind.Computation, weight: 1 }); ArbMultiGasConstraintsTypes.WeightedResource[] memory storageResources = new ArbMultiGasConstraintsTypes.WeightedResource[](1); storageResources[0] = ArbMultiGasConstraintsTypes.WeightedResource({ resource: ArbMultiGasConstraintsTypes.ResourceKind.StorageGrowth, weight: 1 }); ArbMultiGasConstraintsTypes.ResourceConstraint[] memory constraints = new ArbMultiGasConstraintsTypes.ResourceConstraint[](2); constraints[0] = ArbMultiGasConstraintsTypes.ResourceConstraint({ resources: computeResources, adjustmentWindowSecs: 600, // 10-minute adjustment window targetPerSec: 7_000_000, // 7M gas/sec compute target backlog: 0 }); constraints[1] = ArbMultiGasConstraintsTypes.ResourceConstraint({ resources: storageResources, adjustmentWindowSecs: 3600, // 1-hour adjustment window targetPerSec: 1_000_000, // 1M gas/sec storage target backlog: 0 }); OWNER.setMultiGasPricingConstraints(constraints); } /// @notice Read back the active multi-gas constraints and their current backlogs. function readMultiGasConstraints() external view returns (ArbMultiGasConstraintsTypes.ResourceConstraint[] memory) { return GAS_INFO.getMultiGasPricingConstraints(); } } ``` -------------------------------- ### getConstraints Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Returns all active multi-constraint configurations for the gas pricing model (ArbOS ≥50). ```APIDOC ## getConstraints ### Description Returns all active multi-constraint configurations for the gas pricing model. ### Method VIEW ### Returns - **constraints** (uint64[3][]) - A 2D array where each inner array represents a constraint configuration: `[gasTargetPerSec, adjustmentWindowSecs, currentBacklog]`. ### Response Example { "constraints": [ ["10000000", "600", "5000000"], ["12000000", "600", "6000000"] ] } ``` -------------------------------- ### Inspect Gas Fees with ArbGasInfo Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt This contract demonstrates how to use the ArbGasInfo precompile to retrieve various gas fee-related information. It requires importing the ArbGasInfo interface. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@arbitrum/nitro-precompile-interfaces/ArbGasInfo.sol"; import "@arbitrum/nitro-precompile-interfaces/ArbMultiGasConstraintsTypes.sol"; contract GasInspector { ArbGasInfo constant GAS_INFO = ArbGasInfo(0x000000000000000000000000000000000000006c); struct FeeSnapshot { uint256 l1BaseFeeEstimate; // wei uint256 minimumGasPrice; // wei uint256 currentTxL1Fees; // wei paid by this tx for L1 data int256 l1PricingSurplus; // may be negative } function getFeeSnapshot() external view returns (FeeSnapshot memory snap) { snap.l1BaseFeeEstimate = GAS_INFO.getL1BaseFeeEstimate(); snap.minimumGasPrice = GAS_INFO.getMinimumGasPrice(); snap.currentTxL1Fees = GAS_INFO.getCurrentTxL1GasFees(); snap.l1PricingSurplus = GAS_INFO.getL1PricingSurplus(); } /// @notice Returns full price breakdown in wei for the 6 cost components. function getPricesInWei() external view returns ( uint256 perL2Tx, uint256 perL1CalldataByte, uint256 perStorageAlloc, uint256 perArbGasBase, uint256 perArbGasCongestion, uint256 perArbGasTotal ) { return GAS_INFO.getPricesInWei(); } /// @notice Returns backlog state (single-constraint model, pre-ArbOS 50 or fallback). function getBacklogState() external view returns ( uint256 speedLimitPerSecond, uint256 gasPoolMax, uint256 maxBlockGasLimit, uint64 gasBacklog, uint64 pricingInertia, uint64 backlogTolerance ) { (speedLimitPerSecond, gasPoolMax, maxBlockGasLimit) = GAS_INFO.getGasAccountingParams(); gasBacklog = GAS_INFO.getGasBacklog(); pricingInertia = GAS_INFO.getPricingInertia(); backlogTolerance = GAS_INFO.getGasBacklogTolerance(); } /// @notice Returns per-resource base fees from the multi-dimensional pricing model (ArbOS ≥60). /// Index corresponds to ArbMultiGasConstraintsTypes.ResourceKind enum value. function getMultiGasBaseFees() external view returns (uint256[] memory baseFees) { baseFees = GAS_INFO.getMultiGasBaseFee(); // baseFees[1] = Computation base fee (wei) // baseFees[4] = StorageAccessWrite base fee (wei) // baseFees[5] = StorageGrowth base fee (wei) } /// @notice Returns all active multi-constraint configurations (ArbOS ≥50). function getConstraints() external view returns (uint64[3][] memory constraints) { constraints = GAS_INFO.getGasPricingConstraints(); // Each entry: [gasTargetPerSec, adjustmentWindowSecs, currentBacklog] } } ``` -------------------------------- ### configureMultiConstraints Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Configures the multi-constraint gas pricing model (available from ArbOS version 50). Passing an empty array reverts to the single-constraint model. This function is only callable by chain owners. ```APIDOC ## configureMultiConstraints ### Description Configures the multi-constraint gas pricing model (available from ArbOS version 50). Passing an empty array reverts to the single-constraint model. This function is only callable by chain owners. ### Method `setGasPricingConstraints(uint64[3][] calldata constraints)` ### Parameters - **constraints** (uint64[3][]) - An array of constraints, where each constraint is an array of three uint64 values: `[gasTargetPerSec, adjustmentWindowSecs, startingBacklog]`. ### Request Example ```solidity // Example: two constraints — compute and storage // ARB_OWNER.setGasPricingConstraints(constraints); ``` ``` -------------------------------- ### Listening for ArbRetryableTx Events with ethers.js Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt This JavaScript snippet shows how to listen for events emitted by the ArbRetryableTx precompile using the ethers.js library. It demonstrates setting up listeners for ticket creation, scheduled redemptions, and cancellations. ```javascript // Listening for ticket events off-chain (ethers.js):\n//\n// const retryable = new ethers.Contract("0x...6e", abi, provider);\n// retryable.on("TicketCreated", (ticketId) => console.log("Created:", ticketId));\n// retryable.on("RedeemScheduled", (ticketId, retryTxHash, seq, gas, donor) =>\n// console.log("Redeem scheduled, seq:", seq.toString()));\n// retryable.on("Canceled", (ticketId) => console.log("Canceled:", ticketId)); ``` -------------------------------- ### configureMultiGas Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Configures the multi-dimensional multi-gas pricing model (available from ArbOS version 60). This function is only callable by chain owners. ```APIDOC ## configureMultiGas ### Description Configures the multi-dimensional multi-gas pricing model (available from ArbOS version 60). This function is only callable by chain owners. ### Method `setMultiGasPricingConstraints(ArbMultiGasConstraintsTypes.ResourceConstraint[] calldata constraints)` ### Parameters - **constraints** (ArbMultiGasConstraintsTypes.ResourceConstraint[]) - An array of resource constraints for multi-gas pricing. ### Request Example ```solidity // ARB_OWNER.setMultiGasPricingConstraints(constraints); ``` ``` -------------------------------- ### getPricesInWei Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Returns the price breakdown in wei for the six cost components of gas. ```APIDOC ## getPricesInWei ### Description Returns the price breakdown in wei for the six cost components of gas. ### Method VIEW ### Returns - **perL2Tx** (uint256) - Cost per L2 transaction in wei. - **perL1CalldataByte** (uint256) - Cost per L1 calldata byte in wei. - **perStorageAlloc** (uint256) - Cost per storage allocation in wei. - **perArbGasBase** (uint256) - Base cost per ArbGas unit in wei. - **perArbGasCongestion** (uint256) - Congestion cost per ArbGas unit in wei. - **perArbGasTotal** (uint256) - Total cost per ArbGas unit in wei. ### Response Example { "perL2Tx": "10000000000000000", "perL1CalldataByte": "1000000000000000", "perStorageAlloc": "1000000000000000000", "perArbGasBase": "1000000000000000", "perArbGasCongestion": "500000000000000", "perArbGasTotal": "1500000000000000" } ``` -------------------------------- ### ArbWasm - Stylus Program Lifecycle Management Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt The ArbWasm precompile manages the activation, versioning, expiry, keepalive, and gas parameter introspection for Stylus (WASM-based) smart contracts. ```APIDOC ## ArbWasm — Stylus Program Lifecycle **Address:** `0x0000000000000000000000000000000000000071` *(ArbOS ≥30)* `ArbWasm` manages the lifecycle of Stylus (WASM-based) smart contracts: activation, versioning, expiry, keepalive, and gas parameter introspection. Before a Stylus program can be called, it must be activated via `activateProgram`, which validates the WASM bytecode and charges a data fee. ### activateProgram Activates a deployed Stylus program, paying the required data fee. `msg.value` must cover the `dataFee`; any excess is refunded. - **program** (address) - The address of the Stylus program to activate. **Returns:** - **version** (uint16) - The activated version of the program. - **dataFee** (uint256) - The data fee charged for activation. ### stylusVersion Returns the current Stylus version. **Returns:** - **version** (uint16) - The current Stylus version. ### programVersion Retrieves the version of a specific Stylus program. - **program** (address) - The address of the Stylus program. **Returns:** - **version** (uint16) - The version of the Stylus program. ### programInitGas Gets gas cost estimates for invoking the program. - **program** (address) - The address of the Stylus program. **Returns:** - **gasUncached** (uint64) - Gas cost when the program is not in the ArbOS cache. - **gasCached** (uint64) - Gas cost when the program was recently used (in-cache). ### codehashKeepalive Extends the expiry of a program identified by its code hash. Reverts if called too soon (before `expiryDays()` have passed since activation). - **codehash** (bytes32) - The code hash of the program. ### inkPrice Introspects the global WASM ink pricing parameter. **Returns:** - **inkPerGas** (uint32) - The ink cost per gas unit. ### maxStackDepth Introspects the global maximum WASM stack depth. **Returns:** - **maxStackDepth** (uint32) - The maximum stack depth. ### freePages Introspects the global number of free WASM pages. **Returns:** - **freePages** (uint16) - The number of free pages. ### pageGas Introspects the global WASM page gas cost. **Returns:** - **pageGas** (uint16) - The gas cost per page. ### pageLimit Introspects the global WASM page limit. **Returns:** - **pageLimit** (uint16) - The maximum number of pages allowed. ### expiryDays Introspects the global WASM program expiry duration in days. **Returns:** - **expiryDays** (uint16) - The expiry duration in days. ``` -------------------------------- ### Manage Stylus Program Cache with ArbWasmCache Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Manages Stylus program caching using the ArbWasmCache interface. Allows authorized managers to pin programs into the cache for reduced invocation costs or evict them by code hash. Checks if a program is cached and lists authorized cache managers. ```Solidity // SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport "@arbitrum/nitro-precompile-interfaces/ArbWasmCache.sol";\n\ncontract CacheManagerHelper {\n ArbWasmCache constant ARB_WASM_CACHE =\n ArbWasmCache(0x0000000000000000000000000000000000000072);\n\n /// @notice Pin a Stylus program into the cache (caller must be a cache manager or chain owner).\n /// Reverts if the program has expired.\n function cacheProgram(address program) external {\n ARB_WASM_CACHE.cacheProgram(program);\n // Available in ArbOS ≥31; use cacheCodehash for ArbOS 30.\n }\n\n /// @notice Evict a cached program by its code hash (cache manager or chain owner only).\n function evict(bytes32 codehash) external {\n ARB_WASM_CACHE.evictCodehash(codehash);\n }\n\n /// @notice Check whether a program is currently cached (may be expired).\n function isCached(bytes32 codehash) external view returns (bool) {\n return ARB_WASM_CACHE.codehashIsCached(codehash);\n }\n\n /// @notice List all authorized cache managers for this chain.\n function getCacheManagers() external view returns (address[] memory) {\n return ARB_WASM_CACHE.allCacheManagers();\n }\n\n /// @notice Check if a specific address has cache manager rights.\n function checkManager(address addr) external view returns (bool) {\n return ARB_WASM_CACHE.isCacheManager(addr);\n }\n} ``` -------------------------------- ### Activate Stylus Program with ArbWasm Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Activates a deployed Stylus program using the ArbWasm interface, paying the required data fee. Ensure msg.value covers the dataFee; excess is refunded. Checks if a program needs re-activation due to version mismatch or expiry. ```Solidity // SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport "@arbitrum/nitro-precompile-interfaces/ArbWasm.sol";\n\ncontract StylusActivator {\n ArbWasm constant ARB_WASM = ArbWasm(0x0000000000000000000000000000000000000071);\n\n event Activated(address program, uint16 version, uint256 dataFee);\n\n /// @notice Activate a deployed Stylus program, paying the required data fee.\n /// msg.value must cover the dataFee; any excess is refunded.\n function activate(address program) external payable returns (uint16 version, uint256 dataFee) {\n (version, dataFee) = ARB_WASM.activateProgram{value: msg.value}(program);\n require(msg.value >= dataFee, "Insufficient fee");\n emit Activated(program, version, dataFee);\n }\n\n /// @notice Check whether a program needs re-activation (version mismatch or expired).\n function needsActivation(address program) external view returns (bool) {\n uint16 current = ARB_WASM.stylusVersion();\n uint16 progVer;\n try ARB_WASM.programVersion(program) returns (uint16 v) {\n progVer = v;\n } catch {\n return true; // Not activated at all\n }\n return progVer < current;\n }\n\n /// @notice Get gas cost estimates for invoking the program.\n function getInitGas(address program)\n external\n view\n returns (uint64 gasUncached, uint64 gasCached)\n {\n (gasUncached, gasCached) = ARB_WASM.programInitGas(program);\n // gasUncached: gas cost when program is not in ArbOS cache\n // gasCached: gas cost when program was recently used (in-cache)\n }\n\n /// @notice Extend expiry of a program identified by its code hash.\n function keepalive(bytes32 codehash) external payable {\n ARB_WASM.codehashKeepalive{value: msg.value}(codehash);\n // Reverts if called too soon (before keepaliveDays() have passed since activation)\n }\n\n /// @notice Introspect global WASM pricing parameters.\n function getWasmParams()\n external\n view\n returns (\n uint32 inkPerGas,\n uint32 maxStackDepth,\n uint16 freePages,\n uint16 pageGas,\n uint16 pageLimit,\n uint16 expiryDays\n )\n {\n inkPerGas = ARB_WASM.inkPrice();\n maxStackDepth = ARB_WASM.maxStackDepth();\n freePages = ARB_WASM.freePages();\n pageGas = ARB_WASM.pageGas();\n pageLimit = ARB_WASM.pageLimit();\n expiryDays = ARB_WASM.expiryDays();\n }\n} ``` -------------------------------- ### getFeeSnapshot Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Retrieves a snapshot of current fee information including L1 base fee estimate, minimum gas price, L1 fees paid by the current transaction, and L1 pricing surplus. ```APIDOC ## getFeeSnapshot ### Description Retrieves a snapshot of current fee information. ### Method VIEW ### Returns - **l1BaseFeeEstimate** (uint256) - The estimated L1 base fee in wei. - **minimumGasPrice** (uint256) - The minimum gas price in wei. - **currentTxL1Fees** (uint256) - The L1 fees paid by this transaction for L1 data in wei. - **l1PricingSurplus** (int256) - The L1 pricing surplus, which may be negative, in wei. ### Response Example { "l1BaseFeeEstimate": "10000000000000000", "minimumGasPrice": "10000000000000000", "currentTxL1Fees": "5000000000000000", "l1PricingSurplus": "-1000000000000000" } ``` -------------------------------- ### getBacklogState Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Returns the current backlog state of the gas accounting system, relevant for the single-constraint gas model. ```APIDOC ## getBacklogState ### Description Returns the current backlog state of the gas accounting system. ### Method VIEW ### Returns - **speedLimitPerSecond** (uint256) - The speed limit in gas per second. - **gasPoolMax** (uint256) - The maximum capacity of the gas pool. - **maxBlockGasLimit** (uint256) - The maximum gas limit for a block. - **gasBacklog** (uint64) - The current gas backlog. - **pricingInertia** (uint64) - The pricing inertia factor. - **backlogTolerance** (uint64) - The backlog tolerance level. ### Response Example { "speedLimitPerSecond": "10000000", "gasPoolMax": "1000000000", "maxBlockGasLimit": "100000000", "gasBacklog": "5000000", "pricingInertia": "10", "backlogTolerance": "1000000" } ``` -------------------------------- ### ArbWasmCache - Stylus Cache Management Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt The ArbWasmCache precompile allows authorized cache managers to pin Stylus programs into the ArbOS in-memory cache, reducing their invocation cost. ```APIDOC ## ArbWasmCache — Stylus Cache Management **Address:** `0x0000000000000000000000000000000000000072` *(ArbOS ≥30)* `ArbWasmCache` allows authorized cache managers (set via `ArbOwner`) to pin Stylus programs into the ArbOS in-memory cache, reducing their invocation cost. Cache managers are typically specialized smart contracts that manage bidding for cache slots. ### cacheProgram Pins a Stylus program into the cache. The caller must be a cache manager or chain owner. Reverts if the program has expired. - **program** (address) - The address of the Stylus program to cache. *Note: Available in ArbOS ≥31; use `cacheCodehash` for ArbOS 30.* ### evictCodehash Evicts a cached program by its code hash. Only cache managers or the chain owner can call this. - **codehash** (bytes32) - The code hash of the program to evict. ### codehashIsCached Checks whether a program is currently cached (may be expired). - **codehash** (bytes32) - The code hash of the program. **Returns:** - **isCached** (bool) - True if the program is cached, false otherwise. ### allCacheManagers Lists all authorized cache managers for this chain. **Returns:** - **managers** (address[]) - An array of addresses of the cache managers. ### isCacheManager Checks if a specific address has cache manager rights. - **addr** (address) - The address to check. **Returns:** - **isManager** (bool) - True if the address is a cache manager, false otherwise. ``` -------------------------------- ### getMultiGasBaseFees Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Returns the per-resource-kind base fees used by the multi-dimensional gas model (ArbOS ≥60). ```APIDOC ## getMultiGasBaseFees ### Description Returns the per-resource-kind base fees from the multi-dimensional pricing model. ### Method VIEW ### Returns - **baseFees** (uint256[]) - An array of base fees in wei, indexed by `ArbMultiGasConstraintsTypes.ResourceKind`. ### Response Example { "baseFees": [ "0", "1000000000000000", "0", "0", "500000000000000", "1000000000000000" ] } ``` -------------------------------- ### Retryable Ticket Management Contract Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt This Solidity contract demonstrates how to interact with the ArbRetryableTx precompile for managing retryable tickets. It includes functions for redeeming, extending, canceling, and querying ticket information. ```solidity // SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport "@arbitrum/nitro-precompile-interfaces/ArbRetryableTx.sol";\n\ncontract RetryableManager {\n ArbRetryableTx constant RETRYABLE =\n ArbRetryableTx(0x000000000000000000000000000000000000006e);\n\n event RetryableRedeemed(bytes32 ticketId, bytes32 retryTxHash);\n event RetryableExtended(bytes32 ticketId, uint256 newTimeout);\n\n /// @notice Manually redeem a failed L1->L2 retryable ticket.\n /// Donates all remaining gas to the redemption attempt.\n /// @param ticketId keccak256(keccak256(chainId, inboxSequenceNumber), 0)\n function redeemTicket(bytes32 ticketId) external returns (bytes32 retryTxHash) {\n retryTxHash = RETRYABLE.redeem(ticketId);\n emit RetryableRedeemed(ticketId, retryTxHash);\n }\n\n /// @notice Extend a ticket's lifetime by one full lifetime period.\n /// Reverts if the ticket already has more than one lifetime remaining.\n function extendTicket(bytes32 ticketId) external returns (uint256 newTimeout) {\n newTimeout = RETRYABLE.keepalive(ticketId);\n emit RetryableExtended(ticketId, newTimeout);\n // Caller pays gas for the extension; donate extra gas when calling.\n }\n\n /// @notice Cancel a ticket and refund its call value to the beneficiary.\n /// Only the beneficiary may call this.\n function cancelTicket(bytes32 ticketId) external {\n address beneficiary = RETRYABLE.getBeneficiary(ticketId);\n require(msg.sender == beneficiary, "Only beneficiary");\n RETRYABLE.cancel(ticketId);\n }\n\n /// @notice Inspect a ticket's status.\n function getTicketInfo(bytes32 ticketId)\n external\n view\n returns (\n uint256 timeout,\n address beneficiary,\n uint256 lifetime\n ) {\n timeout = RETRYABLE.getTimeout(ticketId); // Unix timestamp of expiry\n beneficiary = RETRYABLE.getBeneficiary(ticketId);\n lifetime = RETRYABLE.getLifetime(); // Minimum ticket lifetime in seconds\n }\n\n /// @notice Returns the redeemer of the currently executing retryable (address(0) if not a redeem).\n function getCurrentRedeemer() external view returns (address) {\n return RETRYABLE.getCurrentRedeemer();\n }\n} ``` -------------------------------- ### ArbMultiGasConstraintsTypes - readMultiGasConstraints Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Reads back the active multi-gas constraints and their current backlogs. This view function allows querying the current gas pricing configuration of the chain. ```APIDOC ## readMultiGasConstraints ### Description Reads back the active multi-gas constraints and their current backlogs. This function returns an array of `ArbMultiGasConstraintsTypes.ResourceConstraint` which details the gas pricing configuration for different resources. ### Method View Call ### Parameters None ### Response #### Success Response (200) - **constraints** (ArbMultiGasConstraintsTypes.ResourceConstraint[]) - An array of resource constraints. ### Response Example ```json { "constraints": [ { "resources": [ { "resource": "Computation", "weight": 1 } ], "adjustmentWindowSecs": 600, "targetPerSec": 7000000, "backlog": 0 }, { "resources": [ { "resource": "StorageGrowth", "weight": 1 } ], "adjustmentWindowSecs": 3600, "targetPerSec": 1000000, "backlog": 0 } ] } ``` ``` -------------------------------- ### ArbAddressTable Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Provides functionality for address compression by mapping addresses to compact integer indices. While deprecated in Nitro, it remains available for backward compatibility. ```APIDOC ## ArbAddressTable — Address Compression (Deprecated) **Address:** `0x0000000000000000000000000000000000000066` `ArbAddressTable` was designed for calldata compression by mapping addresses to compact integer indices. It is deprecated in Nitro (calldata compression is now handled at the batch level) but remains available for backwards compatibility. ### register - **Description**: Registers an address and returns its compact index. If the address is already registered, it returns the existing index (idempotent). - **Method**: `external` - **Parameters**: - `addr` (address) - The address to register. - **Returns**: - `uint256` - The compact index of the registered address. ### lookup - **Description**: Looks up the compact index of an already-registered address. - **Method**: `external view` - **Parameters**: - `addr` (address) - The address to look up. - **Returns**: - `uint256` - The compact index of the address. - **Reverts**: If the address is not registered. ### lookupIndex - **Description**: Resolves a compact index back to its original address. - **Method**: `external view` - **Parameters**: - `index` (uint256) - The compact index to resolve. - **Returns**: - `address` - The original address corresponding to the index. - **Reverts**: If the index is out of bounds (>= size()). ### compress - **Description**: Compresses an address into its table-index bytes representation. Registers the address if it's not already present. - **Method**: `external` - **Parameters**: - `addr` (address) - The address to compress. - **Returns**: - `bytes memory` - The compressed byte representation of the address. ``` -------------------------------- ### Schedule ArbOS Upgrade Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Schedules an ArbOS upgrade to a new version at a specified future Unix timestamp. Ensure the timestamp is in the future. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@arbitrum/nitro-precompile-interfaces/ArbOwner.sol"; import "@arbitrum/nitro-precompile-interfaces/ArbMultiGasConstraintsTypes.sol"; // Only callable by an address that is a chain owner. contract ChainAdminActions { ArbOwner constant ARB_OWNER = ArbOwner(0x0000000000000000000000000000000000000070); /// @notice Schedule an ArbOS upgrade to newVersion at a future Unix timestamp. function scheduleUpgrade(uint64 newVersion, uint64 timestamp) external { ARB_OWNER.scheduleArbOSUpgrade(newVersion, timestamp); // Example: scheduleArbOSUpgrade(32, block.timestamp + 7 days) } /// @notice Update the speed limit (single-constraint model target). function setSpeedLimit(uint64 gasPerSecond) external { ARB_OWNER.setSpeedLimit(gasPerSecond); // e.g. 7_000_000 gas/sec on Arbitrum One } /// @notice Configure multi-constraint pricing model (ArbOS ≥50). /// Passing an empty array switches back to the single-constraint model. function configureMultiConstraints(uint64[3][] calldata constraints) external { // Each entry: [gasTargetPerSec, adjustmentWindowSecs, startingBacklog] // Example: two constraints — compute and storage ARB_OWNER.setGasPricingConstraints(constraints); } /// @notice Configure multi-dimensional multi-gas pricing (ArbOS ≥60). function configureMultiGas( ArbMultiGasConstraintsTypes.ResourceConstraint[] calldata constraints ) external { ARB_OWNER.setMultiGasPricingConstraints(constraints); } /// @notice Add a new chain owner. function addOwner(address newOwner) external { ARB_OWNER.addChainOwner(newOwner); } /// @notice Redirect filtered transaction funds to a designated recipient (ArbOS ≥60). function setFilteredFundsRecipient(address recipient) external { ARB_OWNER.setFilteredFundsRecipient(recipient); } /// @notice Enable or disable tip collection (ArbOS ≥60). function setTipCollection(bool enable) external { ARB_OWNER.setCollectTips(enable); } } ``` -------------------------------- ### setTipCollection Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Enables or disables the collection of tips (available from ArbOS version 60). This function is only callable by chain owners. ```APIDOC ## setTipCollection ### Description Enables or disables the collection of tips (available from ArbOS version 60). This function is only callable by chain owners. ### Method `setCollectTips(bool enable)` ### Parameters - **enable** (bool) - `true` to enable tip collection, `false` to disable. ### Request Example ```solidity // ARB_OWNER.setCollectTips(enable); ``` ``` -------------------------------- ### addOwner Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Adds a new address to the list of chain owners. This function is only callable by chain owners. ```APIDOC ## addOwner ### Description Adds a new address to the list of chain owners. This function is only callable by chain owners. ### Method `addChainOwner(address newOwner)` ### Parameters - **newOwner** (address) - The address of the new chain owner to add. ### Request Example ```solidity // ARB_OWNER.addChainOwner(newOwner); ``` ``` -------------------------------- ### Query Chain Governance with ArbOwnerPublic Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Use ArbOwnerPublic to query chain ownership, scheduled upgrades, fee accounts, and feature flags. This interface is read-only and callable by anyone. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@arbitrum/nitro-precompile-interfaces/ArbOwnerPublic.sol"; contract ChainGovernanceReader { ArbOwnerPublic constant PUBLIC = ArbOwnerPublic(0x000000000000000000000000000000000000006b); /// @notice Returns true if addr is a chain owner. function isOwner(address addr) external view returns (bool) { return PUBLIC.isChainOwner(addr); } /// @notice Returns the next scheduled ArbOS upgrade version and timestamp. /// Returns (0, 0) if no upgrade is scheduled. function getScheduledUpgrade( ) external view returns (uint64 arbosVersion, uint64 scheduledFor) { (arbosVersion, scheduledFor) = PUBLIC.getScheduledUpgrade(); } /// @notice Returns network and infrastructure fee collector addresses. function getFeeAccounts( ) external view returns (address networkFee, address infraFee) { networkFee = PUBLIC.getNetworkFeeAccount(); infraFee = PUBLIC.getInfraFeeAccount(); } /// @notice Returns all current chain owners. function getOwners() external view returns (address[] memory) { return PUBLIC.getAllChainOwners(); } /// @notice Returns all authorized transaction filterers (ArbOS ≥60). function getFilterers() external view returns (address[] memory) { return PUBLIC.getAllTransactionFilterers(); } /// @notice Returns current chain configuration flags. function getFlags( ) external view returns ( bool calldataPriceIncreaseEnabled, bool collectTips, uint64 brotliLevel, uint8 maxStylusFragments ) { calldataPriceIncreaseEnabled = PUBLIC.isCalldataPriceIncreaseEnabled(); collectTips = PUBLIC.getCollectTips(); // ArbOS ≥60 brotliLevel = PUBLIC.getBrotliCompressionLevel(); // ArbOS ≥20 maxStylusFragments = PUBLIC.getMaxStylusContractFragments(); // ArbOS ≥60 } } ``` -------------------------------- ### Interact with ArbSys for L2 Info and Messaging Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Use the ArbSys interface to retrieve L2 block numbers, chain IDs, ArbOS versions, and to send ETH or arbitrary data to L1. Note that L2-to-L1 messages require a ~7-day challenge period before execution on L1. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@arbitrum/nitro-precompile-interfaces/ArbSys.sol"; contract L2Info { ArbSys constant ARB_SYS = ArbSys(address(100)); // 0x...64 /// @notice Returns the Arbitrum L2 block number (not the L1 block number). function getL2BlockNumber() external view returns (uint256) { return ARB_SYS.arbBlockNumber(); // e.g. 245_000_000 on Arbitrum One } /// @notice Returns this chain's unique chain ID. function getChainId() external view returns (uint256) { return ARB_SYS.arbChainID(); // Arbitrum One => 42161, Arbitrum Nova => 42170 } /// @notice Returns ArbOS version encoded as 55 + nitroArbOSVersion. /// ArbOS 31 => returns 86. function getArbOSVersion() external view returns (uint256) { return ARB_SYS.arbOSVersion(); } /// @notice Sends ETH from this contract back to an L1 address. /// The returned uint256 is the unique L2→L1 message ID. function bridgeEthToL1(address l1Recipient) external payable returns (uint256 msgId) { msgId = ARB_SYS.withdrawEth{value: msg.value}(l1Recipient); // After the ~7-day challenge period, call Outbox.executeTransaction on L1 to claim. } /// @notice Sends an arbitrary cross-chain message to an L1 contract. function sendMessageToL1( address l1Contract, bytes calldata payload ) external payable returns (uint256 msgId) { msgId = ARB_SYS.sendTxToL1{value: msg.value}(l1Contract, payload); } /// @notice Returns the current Merkle tree state of all L2→L1 sends. function getMerkleState( ) external view returns (uint256 size, bytes32 root, bytes32[] memory partials) { (size, root, partials) = ARB_SYS.sendMerkleTreeState(); } /// @notice Maps an L1 contract address to its L2 alias (adds 0x1111...1111). function getL2Alias(address l1Contract) external pure returns (address) { ArbSys arbSys = ArbSys(address(100)); return arbSys.mapL1SenderContractAddressToL2Alias(l1Contract, address(0)); } } // Listening for L2→L1 events off-chain (ethers.js): // // const arbSys = new ethers.Contract("0x0000000000000000000000000000000000000064", arbSysAbi, provider); // arbSys.on("L2ToL1Tx", (caller, destination, hash, position, arbBlockNum, ethBlockNum, ts, value, data) => { // console.log(`L2→L1 tx #${position.toString()} to ${destination}, hash=${hash}`); // }); ``` -------------------------------- ### ArbDebug - becomeChainOwner Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt Makes the caller the chain owner. This function is only available in debug mode and is intended for testing purposes. ```APIDOC ## becomeChainOwner ### Description Makes the caller the chain owner. This function is intended for testing and is only accessible when the Arbitrum chain is running in debug mode. ### Method External Call ### Parameters None ### Response None (modifies chain state) ``` -------------------------------- ### Address Table Operations with ArbAddressTable (Deprecated) Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt This contract provides functionality to register, look up, and compress addresses into compact indices. It is deprecated in Nitro but available for backward compatibility. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@arbitrum/nitro-precompile-interfaces/ArbAddressTable.sol"; contract AddressTableExample { ArbAddressTable constant ADDR_TABLE = ArbAddressTable(0x0000000000000000000000000000000000000066); /// @notice Register an address and return its compact index. function registerAddress(address addr) external returns (uint256 index) { index = ADDR_TABLE.register(addr); // If already registered, returns existing index (idempotent). } /// @notice Look up the index of an already-registered address. function lookupAddress(address addr) external view returns (uint256 index) { require(ADDR_TABLE.addressExists(addr), "Not registered"); index = ADDR_TABLE.lookup(addr); } /// @notice Resolve an index back to its address. function resolveIndex(uint256 index) external view returns (address) { return ADDR_TABLE.lookupIndex(index); // Reverts if index >= size() } /// @notice Compress an address into its table-index bytes representation. function compressAddr(address addr) external returns (bytes memory compressed) { compressed = ADDR_TABLE.compress(addr); // Registers addr if not already present, then returns compact bytes. } } ``` -------------------------------- ### Manage Batch Posters and Fee Collectors with ArbAggregator Source: https://context7.com/offchainlabs/nitro-precompile-interfaces/llms.txt This contract allows querying and updating batch poster addresses and their associated fee collectors. Adding new batch posters requires chain owner privileges. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@arbitrum/nitro-precompile-interfaces/ArbAggregator.sol"; contract BatchPosterInfo { ArbAggregator constant AGG = ArbAggregator(0x000000000000000000000000000000000000006d); /// @notice Returns all current batch poster addresses. function getBatchPosters() external view returns (address[] memory) { return AGG.getBatchPosters(); } /// @notice Returns the fee collector for a given batch poster. function getFeeCollector(address batchPoster) external view returns (address) { return AGG.getFeeCollector(batchPoster); } /// @notice Update the fee collector for a batch poster. /// Caller must be the batch poster, its current fee collector, or a chain owner. function updateFeeCollector(address batchPoster, address newCollector) external { AGG.setFeeCollector(batchPoster, newCollector); } /// @notice Add a new batch poster (chain owner only). function addBatchPoster(address newPoster) external { AGG.addBatchPoster(newPoster); } } ```