We at Madfish want to allow users to send their FA1.2 - FA2 tokens without holding XTZ on the user’s account. As a solution, we are developing a prototype of a Tezos Gas Station Relayer.
Architectural overview of a Gas Station
Gas Station is a backend application with a few endpoints for accepting permits and parameters. We imagine wallet-relayer interoperation as follows:
Wallet asks the server if it supports a specific TZIP-17 compatible token and its current price. It forms the desired transaction and creates a permit for the gas station to be able to send it on the user’s behalf. Then the user crafts a transfer to reward GSN for gas in tokens and again permits for a third party to submit it to the Tezos network. All this info then sent to the server using the usual HTTP POST request. The server validates all the data and sends it to the network paying for the gas if fees are satisfactory. Transactions being batched provides guarantees of atomicity: either transaction is done as a whole or fails completely.
At the current stage, we have created an early stage prototype of the gas station that accepts next requests:
- /submit - accepts JSON with permit params and call params.
/supported_tokens - get which tokens are supported by the specific relayer
/price <token_address> - get current gas price for a specific token
/address - fees destination address
Arbitrary call submission consists of two parts and both are mandatory and thoroughly validated by the server. The first part is a call and parameters intended to be called by the user and the second part is a Transfer to the gas station address. Both of these parts have corresponding permits. After making sure received parameter hashes are matching and signed appropriately, server performs transactions in the following order:
- Submit user’s action permit and fee payment permit
- Call to user’s action
- Transfer fee to our backend’s address on behalf of the user
All these transactions are batched to ensure atomicity and decrease gas price.
Optimized transfer payload
In case a user makes a simple transfer, we may take advantage of FA2’s ability to perform a few transfers in a single call and optimize it so only one permit and one contract call is performed, making it considerably cheaper.
As for now, no discovery mechanisms are planned: wallets will just have a whitelist of known gas stations and will poll them to discover if they are available. But it is possible to implement some kind of DNS system or just a simple endpoint /neighbours advertising recommended backends available to interact with.
Our next steps
We will continue to explore the possibilities of creating a gas station on the Tezos network. The first implementation is planned for our wallet. We’ll be sharing our progress with the community and discussing possible ways for improvement.