How Tonkeeper Brings Gasless Transactions to TON

Tonkeeper Battery and Gasless are innovative features to help people use TON without having to buy Toncoin. This article explains how Battery and Gasless are implemented, the features and tradeoffs.

The Onboarding Problem

TON is a “multi-asset” blockchain network. In addition to its built-in cryptocurrency called Toncoin, TON has all sorts of fungible tokens: The stablecoin USDT, staked “tsTON”, tap-to-earn Notcoin and many others. There are also many forms of non-fungible tokens, or NFTs, ranging from art, collectibles, tokenized usernames or domain names - and more.

When using TON for the first time, many people may not have Toncoin or any intent to buy some. Users may have received a payment in USDT or an NFT prize in a contest. In these situations, these users cannot do anything with these cryptocurrencies until they have some Toncoin to pay blockchain fees. Gasless and Battery are features that solve this problem for all newcomers - by helping pay the blockchain fees differently without having to acquire Toncoin first.

Gas and Gasless

Every transaction on a blockchain consumes computational resources. This is measured in units of “gas”.  This gas fee is paid using the built-in cryptocurrency on TON — Toncoin.

“Gasless transactions'' mean users don’t have to worry about gas. It does not mean that gas goes away or fees become free. It means not worrying about having enough Toncoin to pay the fees. For example, “gasless USDT” is paid with USDT from the balance of a user’s account.

What is Tonkeeper Battery?

Tonkeeper Battery is a small, offchain account in Tonkeeper that pays fees on a user’s behalf when they don’t have Toncoin. The Battery is denominated in charges: One charge is the fee for a simple Toncoin transfer, 5-10 charges for a token or NFT transaction and more charges for complex transactions such as swaps. Users can charge the Battery in a variety of ways - in-app purchases using a bank card, USDT and even cryptocurrencies like Notcoin. Then the Battery can be used for transaction fees on all sorts of transactions. These include transferring tokens, NFTs, operations with staking pools and DNS records.

The Difference Between Gasless and Battery

Gasless makes transactions just work - without any additional setup. There is no need to buy Toncoins, and no need to charge the Battery. However, Gasless is limited to fungible cryptocurrency tokens with known behavior and low volatility, such as the stablecoin USDT, among others.

The Battery does not have this limitation. It is charged by the user and can be used with all sorts of transactions. This includes the transfer of any tokens, NFTs and other actions with smart contracts.

Charging Battery with tokens

To charge the Battery with supported cryptocurrency tokens, simply send them to the TON address battery.ton from the wallet that needs a charge. When a user signs a transfer to battery.ton, Tonkeeper doesn’t send that transaction to the TON network. It instead sends it to the Tonkeeper Relay Service. The Relay Service inspects the transaction and verifies it could pay for a minimum amount of charges. Then, it credits the Battery and then publishes the transaction while paying the transaction fee. Once this transaction is complete, the Battery balance is increased and users can make transactions.

Wallet Abstraction 🔥W5

This architecture works thanks to the wallet smart contract version 5, simply called W5. Tonkeeper developed the original technology for gasless transactions and infinite extensibility. The TON Core team, together with Tonkeeper, finalized the open standard in July 2024. The previous standard, wallet version 4, is still supported by all wallets in the TON ecosystem, although without special capabilities for gasless transactions. All new accounts created in Tonkeeper and other TON ecosystem wallets going forward are created with W5 by default. Users can access both v4 and W5 and switch between accounts with ease.

What are wallet smart contracts? In TON there is no special logic for “external messages”, or those that are cryptographically signed by actual users and published on the blockchain. Some contracts may receive an external message and process it. Most often such contracts are “wallet contracts” that implement logic typical for any wallet. This includes checking a cryptographic signature, expiration time, incrementing a sequence number and unpacking embedded messages to send out to other contracts.

Today, most of TON wallets use “version 4 revision 2”, a contract that supports up to 4 simultaneous outgoing messages and extensibility via plugins. W5 improves the design of version 4 in a number of ways, most importantly enabling the relay of signed messages via another contract. This means the user may sign a message to be published on behalf of its wallet and pass it to a relay service. This will wrap it into another transaction and pass it into the user’s wallet.

The relay service spends Toncoin for gas fees, while the user’s wallet passes through all Toncoin with the outgoing messages to pay fees in the downstream contracts. In other words, the user’s signed message is no longer “external”, but becomes an “internal” message. It is capable of carrying not only data, but also Toncoin that pays for gas.

Using Tonkeeper Battery with Version 4 wallets

While version 4 does not support the relay of signed transactions via internal messages, Tonkeeper Battery has worked with v4 wallets since April 2024. Tonkeeper Battery has processed over 2 million transactions by mid-June 2024. When the user signs a transaction, Tonkeeper deducts the expected amount of charges to pay the fees from the Battery account, sends the amount of Toncoin required to cover the gas to the user's wallet, then publishes the user’s transaction. This adds a small delay of about 20 seconds as the wallet contract needs to receive enough Toncoin before processing the transaction.

Gasless with V4 Wallets

This is a combination of the Battery workaround for v4 together with Gasless payments: Every transaction is delayed until the wallet is funded with Toncoin. Then, it sends an extra payment of USDT to the Relay Service.

This is the least efficient and not quite the safest way to implement Gasless transactions. Tonkeeper never supported it, andt instead is migrating to the W5 wallet. MyTonWallet has implemented this mode. However, it had to enforce login by Telegram to protect its relay against potential abuse. This is because users could withdraw Toncoin before their USDT transaction gets completed.

Efficiency

The baseline to measure efficiency of Battery and Gasless is a regular token transfer. The table below assembles costs in fees and time (latency). This compares different ways to to use these features across V4 and W5 wallets.

The most efficient way to relay transactions is using a balance of Toncoins. But for convenience for users who don’t have any Toncoin, Battery with W5 wallet the user experience just allows for a simple single transaction on their end. Users pay for the Battery once, and then transactions are relayed directly through the wallet. All with minimal overhead in terms of fees and delays. The least efficient mode is trying to use Gasless with v4: it does the Battery+v4 workaround, but for every single transaction.

USDT transfer modesFees*Latency
Battery W5$0.10 equivalent15 sec
Gasless W5$0.14 equivalent15
Battery V4$0.10 equivalent30
Gasless V4$0.15-$0.25 equivalent30+

NOTE: This chart is assuming user has no TON available to pay for gas fees

*These fee prices are relevant at $7.00 per TON

Download Tonkeepertonkeeper.com

Download Tonkeeper Pro: tonkeeper.com/pro

Follow: en · ru · فارسی · twitter

© 2024 Tonkeeper. All rights reserved.
All trademarks are the property of their respective owners.