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
, andhigh
gas levels, which translate to different percentiles of recent gas prices. To do this, set thetype
topriority
and thepriority_level
to one of the following:low
,medium
, orhigh
. - You can also specify a gas price in wei manually. To do this, set the
type
tocustom
. On chains that have adopted EIP-1559, then setmax_priority_fee_per_gas
andmax_fee_per_gas
. On chains that use legacy gas pricing, set thegas_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"
}
}
}