Skip to main content

Try it Live

Run Authorization examples in the interactive playground

Gas Calculations

Calculate gas costs for EIP-7702 authorizations.

Overview

EIP-7702 authorization processing has two gas cost components:
  1. Base cost per authorization: 12,500 gas
  2. Empty account cost: 25,000 gas (if delegated address is empty)
Total cost: (authCount * 12500) + (emptyCount * 25000)

Constants

calculateGasCost

Calculate total gas cost for authorization list.
Parameters:
  • authList: Array of authorizations
  • emptyAccounts: Number of empty accounts being delegated to
Returns: Total gas cost as bigint Formula: (authList.length * 12500) + (emptyAccounts * 25000)

Usage

Examples

All empty accounts:
No empty accounts:
Empty list:
Mixed:

getGasCost

Calculate gas cost for single authorization.
Parameters:
  • auth: Authorization to calculate cost for
  • isEmpty: Whether delegated address is empty
Returns: Gas cost as bigint Formula:
  • If empty: 12500 + 25000 = 37500
  • If not empty: 12500

Usage

Empty Account Detection

What is an Empty Account?

An account is considered empty if:
  • Balance = 0
  • Nonce = 0
  • Code length = 0
  • Storage is empty

Checking if Account is Empty

Counting Empty Accounts

Gas Estimation Patterns

Pre-transaction Estimation

Estimate gas before sending transaction:

With Gas Limit

Check if within gas limit:

Per-Authorization Cost Breakdown

Calculate cost for each authorization:

Optimization Strategies

Minimize Empty Account Delegations

Empty accounts cost more gas. Prefer delegating to deployed contracts:

Batch Size Optimization

Larger batches have better gas efficiency per authorization:

Deduplication

Remove duplicate delegations to save gas:

Gas Cost Tables

Base Costs

Cost per Authorization

Advanced Patterns

Dynamic Gas Pricing

Adjust authorization list based on gas price:

Gas Budget Allocation

Allocate gas budget across authorization types:

Gas Monitoring

Track gas usage during processing:

Testing

Test Gas Calculations

Performance

Gas calculation is O(1):

See Also