Kinetex Docs
Comment on page

Gasless Transactions

Blockchain technology requires keeping native coins for paying gas fees on every blockchain used in the exchange to be able to complete a transaction. Otherwise, the funds may get frozen.
However, keeping track of the balances of all coins required for payments in various networks is quite difficult. The procedure becomes even more complicated when exchanging assets through intermediate networks in the absence of a direct bridge between the original and target blockchains.
Gas payments, a technical feature of blockchain, should not bother users, making their experience with crypto more stressful. Therefore, Kinetex has decided to offer all users a gasless approach.
The gasless technology works by default during automated exchanges. Nodes take over all gas costs, subtracting them from the exchanged assets along with the commission for the completed request.
Currently, relayer's network accepts a variety of tokens as a payment for further gas expenses and uses its own fee calculations.
At Kinetex, gasless transactions are implemented in two ways: "permit"-approach and Gas Escrow service.

Gasless flow with "permit"

Arguably one of the main reasons for the success of EIP-20 tokens lies in the interplay between approve and transferFrom, which allows for tokens to not only be transferred between externally owned accounts (EOA), but to be used in other contracts under application-specific conditions by abstracting away msg.sender as the defining mechanism for token access control.
However, a limiting factor in this design stems from the fact that the EIP-20 approve function itself is defined in terms of msg.sender. This means that the user’s initial action involving EIP-20 tokens must be performed by an EOA. If the user needs to interact with a smart contract, then they need to make 2 transactions (approve and the smart contract call which will internally call transferFrom). Even in the simple use case of paying another person, they need to hold ETH to pay for transaction gas costs.
At the protocol level, the functionality of ERC-20 tokens remains rather limited due to the lack of abstraction in their “approve” method. Simply put, users must hold ETH in their balances in order to be able to interact with any smart contract on Ethereum. ETH is required to pay gas costs when sending an additional transaction, also known as approval, allowing a specific smart contract to use your token.
The issue was addressed in the EIP-2612, and the neat solution is a so-called “permit“ method added to the token structure that allows users to change the permission mapping via a signed message rather than via msg.sender.


Gasless flow with "permit"-complied tokens
Tokens that comply with the EIP-2612 standard can be transferred into a contract without using a network’s native coin.
To do this, a user generates an EIP-712 signature containing the parameters needed to run the permit method.
The message with the signature and parameters is included in the swap calldata, intended for transmission to the network of relay nodes. Thus, using this signature, both the necessary approval and the launch of the exchange process occur in one call to the contract.
At the same time, a commission is charged from the exchanged token, which reimburses the cost of gas. In the same transaction, this commission is transferred to the Fee Collector, where it is further distributed among the node holders.

Gas Escrow service

Kinetex aims to provide the best user experience for transactions in DeFi and eliminate any inconvenience associated with the use of gas.
Suppose a user has a token in a network where they do not have a native coin. Moreover, this token does not support the EIP-2612 standard, which is true for the majority of stablecoins and many other popular tokens. To perform any transaction with the token, the user needs to replenish their balance in a required native coin to pay for gas or give the signed transaction to the relayer (which cannot be done through Metamask, for example).
To solve this problem, Kinetex offers the Gas Escrow Service that can make gas payments for users in any supported network, requiring a small deposit in return (available for withdrawal at any time).
This service has a structure similar to lending solutions but works cross-chain and has the possibility to lend users native coins of supported networks.
On average, the deposit amount can range from $1 to $15, depending on selected networks, the price of native coins, the size of the gas fee, and the maximum gas limit. There is no minimum or maximum amount, though.
For an escrow can be used:
  • positive slippage from exchange operations;
  • NFT received in Kinetex Test Flight program;
  • locked / unlocked KIX tokens;
  • any other supported token on any supported network.
Withdrawal is available at any time if the user has no outstanding debts. Funds placed in escrow are not spent and remain unchanged, provided there are no debts.
Users can request any amount of gas their escrow can cover, with the obligation to pay it back. When repaying, the user needs to pay in full the previously spent amount, the gas fee spent for the transfer of a native coin, and the GasTank fee.


Gas Escrow service flow
This service is completely decentralized and consists of two modules: GasEscrow and GasTank, which are smart contracts located on all supported EVM networks.
GasEscrow is responsible for escrow deposits and withdrawals. When making a deposit, each user specifies the token to be deposited, its amount, and the networks where they need to pay gas.
Given that gas costs vary from network to network, the received amount is distributed among the gas pools for the chosen networks in a way it is enough for the same number of operations.
Chainlink Price Feeds are used to calculate the amount deposited in each pool, and manual calculation is also possible.
The deposit division and its consequent placement in different pools are necessary to protect against double-spend attacks when gas is requested simultaneously in several networks.
GasTank is responsible for storing and distributing gas. It stores information about the amounts of gas issued to each user and accepts repayments for previously issued gas along with a commission for its use.
Chainlink Price Feeds are also used to calculate gas lent to users.
GasEscrow and GasTank modules can be used in different networks. So, a user can have an escrow in USDC on the Ethereum network and request gas for the Fantom network.
At the same time, communication between modules is implemented through Chainlink Oracles that make eth_call requests to blockchain nodes to obtain the results of the view-methods of contracts responsible for displaying the current state of the escrow and the user's debts.
A request to pay for gas from a GasTank is made using the relay nodes API or the internal Kinetex executor.
In the future, it is planned to switch to a distributed network of Kinetex Relay Nodes for all networks.
In addition, a request for gas loans can be made from a GasEscrow contract using cross-chain messaging protocols (Celer IM, Layerzero, etc.).