Gas Fees

Gas fees are the transaction costs required to execute operations on blockchain networks. Understanding and managing gas fees is essential for optimizing transaction costs and ensuring timely execution.

What are Gas Fees?

Gas is the unit measuring computational effort required to execute blockchain operations:

  • Gas Limit — Maximum gas units a transaction can consume
  • Gas Price — Cost per gas unit (in Gwei or wei)
  • Transaction Fee — Gas Limit × Gas Price

How Gas Estimation Works

Before submitting a transaction, Cubewire estimates the required gas to ensure successful execution:

Gas Pricing Model

Cubewire uses EIP-1559 gas pricing, the modern standard introduced with Ethereum's London upgrade. This provides more predictable fees and better user experience.

ParameterDescription
maxFeePerGasMaximum total fee per gas unit (in Gwei)
maxPriorityFeePerGasPriority fee / tip to validators (in Gwei)
gasLimitMaximum gas units to consume

Example:

{
  "gasLimit": "21000",
  "maxFeePerGas": "50",
  "maxPriorityFeePerGas": "2"
}

Benefits of EIP-1559

BenefitDescription
Predictable feesBase fee adjusts automatically based on network congestion
No overpaymentYou only pay base fee + priority fee, even if max fee is higher
Faster inclusionPriority fee incentivizes validators to include your transaction
Better UXGas estimation is more reliable

Note: Gas values are provided in Gwei (human-readable format). Cubewire automatically converts to wei for blockchain submission.

Estimating Gas

Before submitting a transaction, request a gas estimate to get current network fees and recommended parameters.

Estimation Request

Provide the transaction details to receive an accurate gas estimate:

FieldTypeRequiredDescription
typestringNoTransaction type: TRANSFER, CONTRACT_WRITE, CONTRACT_READ, CONTRACT_DEPLOY
recipientstringYesRecipient address (null for contract deployment)
amountstringYesAmount in human-readable format (e.g., "0.1")
assetobjectYesAsset details including network
valuestringNoETH value for contract calls (in ETH)
datastringNoEncoded calldata for contract interactions

Asset Object

FieldTypeRequiredDescription
typestringYescryptocurrency (native) or token (ERC-20)
addressstringNoToken contract address (null for native currency)
symbolstringYesAsset symbol (e.g., ETH, USDC)
decimalsnumberNoToken decimals (default: 18)
networkChainIdnumberYesTarget network chain ID

Example — Native ETH transfer:

{
  "type": "TRANSFER",
  "recipient": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb2",
  "amount": "0.1",
  "asset": {
    "type": "cryptocurrency",
    "address": null,
    "symbol": "ETH",
    "decimals": 18,
    "networkChainId": 1
  }
}

Example — ERC-20 token transfer:

{
  "type": "TRANSFER",
  "recipient": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb2",
  "amount": "100",
  "asset": {
    "type": "token",
    "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "symbol": "USDC",
    "decimals": 6,
    "networkChainId": 1
  }
}

Estimation Response

The API returns both EIP-1559 and legacy gas estimates:

FieldDescription
estimation.gasLimitRecommended gas limit
estimation.gasLimitFormattedGas limit with formatting (e.g., "21,000")
estimation.eip1559.maxFeePerGasGweiMax fee per gas in Gwei
estimation.eip1559.maxPriorityFeePerGasGweiPriority fee in Gwei
estimation.eip1559.totalFeeFormattedEstimated total fee in ETH
networkNetwork details (chainId, name, symbol)

Example response:

{
    "success": true,
    "estimation": {
        "gasLimit": "21000",
        "gasLimitFormatted": "21,000",
        "legacy": {
            "gasPrice": "1086513322",
            "gasPriceGwei": "1.086513322",
            "totalFee": "22816779762000",
            "totalFeeFormatted": "0.000022816779762"
        },
        "eip1559": {
            "maxFeePerGas": "3670148266",
            "maxPriorityFeePerGas": "1500000000",
            "maxFeePerGasGwei": "3.670148266",
            "maxPriorityFeePerGasGwei": "1.5",
            "totalFee": "77073113586000",
            "totalFeeFormatted": "0.000077073113586"
        }
    },
    "network": {
        "chainId": "11155111",
        "name": "Ethereum Sepolia",
        "symbol": "ETH"
    }
}

Tip: Use the Gwei suffixed fields (e.g., maxFeePerGasGwei) for human-readable values, and the raw fields for transaction submission.

Gas Fee Workflow

Error Handling

ErrorDescriptionResolution
Gas estimation failedCannot simulate transactionCheck parameters, contract state, or balance
Insufficient funds for gasWallet lacks native currencyFund the vault with ETH/MATIC
Gas limit exceededTransaction ran out of gasIncrease gas limit
Max fee too lowFee below network minimumIncrease maxFeePerGas

API Reference

For complete API documentation including endpoints, request/response examples, and code samples:

Estimate Gas Fees API Reference