Automate Gas Fee Payments

Fordefi can automatically charge a vault for gas fees that are required in EVM transactions

A gas fee represents the expense tied to executing transactions or contracts on the Ethereum network. Traditionally, these fees are embedded within the blockchain, often requiring payment in native tokens sourced from the initiating address. However, this mechanism of acquiring native tokens from the original vault poses obstacles for users seeking to participate in blockchain applications, ultimately limiting their accessibility and functionality.

Fordefi's Gas Station feature presents an innovative solution to this challenge.

πŸ“˜

Availability

Currently, Gas Station is available only for transactions performed programmatically (through the Fordefi API). It is not available through the Fordefi Web Console. Gas Station is not yet available for Waas applications.

Example

Let's say you are a retail platform and some of your customers deposit only USDC tokens as payment. To move that money out of the paying vault (call it vault1), you would normally need to manually transfer gas fees from a funder vault (call it vault2) to the paying vault (vault1) and only then perform an additional manual transaction to move the funds into the target vault (call it vault3). Since you have many of these transactions, you want a method for automating the process, hassle-fee.

Fordefi Gas Station takes the stress out of managing those gas fees. When you seek to move USDC out of vault1 and into vault3, the Gas Station:

  • Checks that there are sufficient (GAS) funds in vault1 to transfer the USDC to vault3. If so, the transfer is executed.
  • If there are insufficient funds, refuels GAS from vault2 to vault1, then moves the USDC to vault3.

funder field

To designate which vault is the gas fee funder (vault2 in the example above), provide its ID for the funder field in a CreateTransaction request.

In the following example, ERC-20 tokens are transferred from a paying vault (27802ca0-7e36-4c7c-8874-9f23515f5e6a) that uses another vault (ca8fe7db-ab19-4750-b668-d73bec5450be) as funder on the Sepolia testnet.

{
    "signer_type": "api_signer",
    "vault_id": "27802ca0-7e36-4c7c-8874-9f23515f5e6a",
    "note": "note for origin",
    "type": "evm_transaction",
    "details": {
        "funder": "ca8fe7db-ab19-4750-b668-d73bec5450be",
        "type": "evm_transfer",
        "gas": {
            "type": "priority",
            "priority_level": "medium"
        },
        "fail_on_prediction_failure": false,
        "to": "0x9D2745ad9044180f44192220C7da27f8B87F3720",
        "asset_identifier": {
            "type": "evm",
            "details": {
                "type": "erc20",
                "token": {
                    "chain": "evm_ethereum_sepolia",
                    "hex_repr": "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"
                }
            }
        },
        "value": {
            "type": "value",
            "value": "1000"
        }
    }
}

Policy, approval, and signing

Both the refuel transaction and the original transaction have to pass policy rules individually. Similarly, each of the transactions is signed individually.

Confirmation on the blockchain

This is the order of sending transaction to the blockchain:

  1. The gas transaction is sent first.
  2. Once the gas transaction is successfully mined, the original transaction is sent for signing. (Fordefi takes the risk of forks for the benefit of reducing the time interval and the gas-price changes.)

Cancel and accelerate

  • Accelerating the gas transaction is enabled, as any other regular transaction.
  • If the primary transaction is cancelled or accelerated, the same funder is used for the replacement transaction.

The following table summarizes all the possible outcomes for Transaction 1 (the refuel or gas transaction) and Transaction 2 (the original transaction) in several scenarios:

CancelAccelerateAbortBlockedError pushing to chain
Transaction 1
(refuel or gas transaction)
Create replacement transaction with 0 amount;
Abort transaction 2.
Create transaction with updated fee.Abort transaction 1 and transaction 2.Return policy rule of blocked gas transaction and don’t create transaction 2

Return inductive error: the gas station is blocked
If transaction 1 received an error, abort transaction 2
Transaction 2
(original transaction)
Create another gas station transaction with enough fee to pay for the cancel.Create another gas station transaction with enough fee to pay for the acceleration.Abort transaction 2, abort transaction 1 if it’s in the waiting_for_approval state, else do nothing - it can still be signed and mined at a later time.Return policy rule of blocked original transaction. Don’t create transaction 1

πŸ“˜

Multiple transactions

Currently, Fordefi does not allow you to create a transaction requiring Gas Station until all previous such transactions in that vault have been fully mined.