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.
| Parameter | Description |
|---|---|
maxFeePerGas | Maximum total fee per gas unit (in Gwei) |
maxPriorityFeePerGas | Priority fee / tip to validators (in Gwei) |
gasLimit | Maximum gas units to consume |
Example:
{
"gasLimit": "21000",
"maxFeePerGas": "50",
"maxPriorityFeePerGas": "2"
}
Benefits of EIP-1559
| Benefit | Description |
|---|---|
| Predictable fees | Base fee adjusts automatically based on network congestion |
| No overpayment | You only pay base fee + priority fee, even if max fee is higher |
| Faster inclusion | Priority fee incentivizes validators to include your transaction |
| Better UX | Gas 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:
| Field | Type | Required | Description |
|---|---|---|---|
type | string | No | Transaction type: TRANSFER, CONTRACT_WRITE, CONTRACT_READ, CONTRACT_DEPLOY |
recipient | string | Yes | Recipient address (null for contract deployment) |
amount | string | Yes | Amount in human-readable format (e.g., "0.1") |
asset | object | Yes | Asset details including network |
value | string | No | ETH value for contract calls (in ETH) |
data | string | No | Encoded calldata for contract interactions |
Asset Object
| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | cryptocurrency (native) or token (ERC-20) |
address | string | No | Token contract address (null for native currency) |
symbol | string | Yes | Asset symbol (e.g., ETH, USDC) |
decimals | number | No | Token decimals (default: 18) |
networkChainId | number | Yes | Target 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:
| Field | Description |
|---|---|
estimation.gasLimit | Recommended gas limit |
estimation.gasLimitFormatted | Gas limit with formatting (e.g., "21,000") |
estimation.eip1559.maxFeePerGasGwei | Max fee per gas in Gwei |
estimation.eip1559.maxPriorityFeePerGasGwei | Priority fee in Gwei |
estimation.eip1559.totalFeeFormatted | Estimated total fee in ETH |
network | Network 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
Gweisuffixed fields (e.g.,maxFeePerGasGwei) for human-readable values, and the raw fields for transaction submission.
Gas Fee Workflow
Error Handling
| Error | Description | Resolution |
|---|---|---|
Gas estimation failed | Cannot simulate transaction | Check parameters, contract state, or balance |
Insufficient funds for gas | Wallet lacks native currency | Fund the vault with ETH/MATIC |
Gas limit exceeded | Transaction ran out of gas | Increase gas limit |
Max fee too low | Fee below network minimum | Increase maxFeePerGas |
Related Topics
- Networks & Assets — Supported networks and chain IDs
- Transactions — Submitting transactions with gas parameters
- Vaults — Managing vault balances for gas
API Reference
For complete API documentation including endpoints, request/response examples, and code samples:
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.
| Parameter | Description |
|---|---|
maxFeePerGas | Maximum total fee per gas unit (in Gwei) |
maxPriorityFeePerGas | Priority fee / tip to validators (in Gwei) |
gasLimit | Maximum gas units to consume |
Example:
{
"gasLimit": "21000",
"maxFeePerGas": "50",
"maxPriorityFeePerGas": "2"
}
Benefits of EIP-1559
| Benefit | Description |
|---|---|
| Predictable fees | Base fee adjusts automatically based on network congestion |
| No overpayment | You only pay base fee + priority fee, even if max fee is higher |
| Faster inclusion | Priority fee incentivizes validators to include your transaction |
| Better UX | Gas 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:
| Field | Type | Required | Description |
|---|---|---|---|
type | string | No | Transaction type: TRANSFER, CONTRACT_WRITE, CONTRACT_READ, CONTRACT_DEPLOY |
recipient | string | Yes | Recipient address (null for contract deployment) |
amount | string | Yes | Amount in human-readable format (e.g., "0.1") |
asset | object | Yes | Asset details including network |
value | string | No | ETH value for contract calls (in ETH) |
data | string | No | Encoded calldata for contract interactions |
Asset Object
| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | cryptocurrency (native) or token (ERC-20) |
address | string | No | Token contract address (null for native currency) |
symbol | string | Yes | Asset symbol (e.g., ETH, USDC) |
decimals | number | No | Token decimals (default: 18) |
networkChainId | number | Yes | Target 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:
| Field | Description |
|---|---|
estimation.gasLimit | Recommended gas limit |
estimation.gasLimitFormatted | Gas limit with formatting (e.g., "21,000") |
estimation.eip1559.maxFeePerGasGwei | Max fee per gas in Gwei |
estimation.eip1559.maxPriorityFeePerGasGwei | Priority fee in Gwei |
estimation.eip1559.totalFeeFormatted | Estimated total fee in ETH |
network | Network 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
Gweisuffixed fields (e.g.,maxFeePerGasGwei) for human-readable values, and the raw fields for transaction submission.
Gas Fee Workflow
Error Handling
| Error | Description | Resolution |
|---|---|---|
Gas estimation failed | Cannot simulate transaction | Check parameters, contract state, or balance |
Insufficient funds for gas | Wallet lacks native currency | Fund the vault with ETH/MATIC |
Gas limit exceeded | Transaction ran out of gas | Increase gas limit |
Max fee too low | Fee below network minimum | Increase maxFeePerGas |
Related Topics
- Networks & Assets — Supported networks and chain IDs
- Transactions — Submitting transactions with gas parameters
- Vaults — Managing vault balances for gas
API Reference
For complete API documentation including endpoints, request/response examples, and code samples: