Customize Gas

Fordefi simplifies the process of creating EVM transactions by automatically estimating the gas limit and setting the gas price based on current market gas prices. However, users who seek more control can customize the gas price and gas limit of their transactions.

Customize gas price

When creating an EVM transaction, you can specify the gas price, by populating the details.gas field of the Create Transaction request.

There are two ways to specify it:

  • The simplest way is to let Fordefi set the gas price based on the chain's current gas price. You can choose between low, medium, and high gas levels, which translate to different percentiles of recent gas prices. To do this, set the type to priority and the priority_level to one of the following: low, medium, or high.
  • You can also specify a gas price in wei manually. To do this, set the type to custom. On chains that have adopted EIP-1559, then set max_priority_fee_per_gas and max_fee_per_gas. On chains that use legacy gas pricing, set the gas_price.

If you omit the details.gas field altogether, Fordefi will use the medium priority by default.

Examples:

{
    "vault_id": "16b5aa12-509e-4944-b656-cf096515d627",
    "signer_type": "api_signer",
    "type": "evm_transaction",
    "details": {
        "type": "evm_raw_transaction",
        "chain": "ethereum_mainnet",
        "to": "0x565697B5DD1F7Bdc61f774807057D058E5A27cbC",
        "value": "0",
        "data": {
            "type": "hex",
            "hex_data": "0x0d1d7ae50000000000000000000000000000000000000000000000000000000000000006"
        },
        "gas": {  
            "type": "priority",
            "priority_level": "high" 
        }
    }
}

Customize gas limit

The gas limit is the maximum amount of gas that can be used to execute the transaction. By default, it is set automatically by Fordefi using the eth_estimateGas method of the node's JSON-RPC interface.

You can optionally specify a custom gas limit by setting the details.gas.gas_limit field in the Create Transaction request. If omitted, Fordefi will automatically estimate an appropriate gas limit for the transaction.

Example with custom gas limit:

{
    "vault_id": "16b5aa12-509e-4944-b656-cf096515d627",
    "signer_type": "api_signer",
    "type": "evm_transaction",
    "details": {
        "type": "evm_raw_transaction",
        "chain": "ethereum_mainnet",
        "to": "0x565697B5DD1F7Bdc61f774807057D058E5A27cbC",
        "value": "0",
        "data": {
            "type": "hex",
            "hex_data": "0x0d1d7ae50000000000000000000000000000000000000000000000000000000000000006"
        },
        "gas": {
            "type": "priority",
            "priority_level": "medium",
            "gas_limit": "1000000"
        }
    }
}