Gas-less way to purchase ETH for USDC. Help those who stuck with zero ETH and earn reward

Alexander Koval
Coinmonks
Published in
5 min readOct 8, 2023

--

The problem

One of the factors that slows down massive adoption of crypto is a consept of gas. It’s hard to understand for new user why he cannot send his ERC20 tokens if his ETH balance is zero.

Let’s imagine Mike is a shop owner in Venezuela and he decided to adopt crypto payments. He just set up his crypto-wallet and received 100 USDC payment from customer. Obviously, his newly created wallet has zero ETH. Now Mike wants to pay 30 USDC bill to the vendor. He been told that his wallet needs to have ETH to pay transaction fee. But Mike has no idea where and how to get ETH and why he cannot pay commission from his USDC balance. Currently Mike doesn’t have much options:

  • He cannot exchange USDC to ETH using DEX protocols cause to interact with DEX his wallet needs to have some ETH
  • He cannot use centralized exchanges to purchase ETH cause his bank is anti-crypto and rejects any crypto-related transaction
  • The only thing he can do is to ask his friend to lend him some ETH so he could pay gas fee for DEX interaction to exchange USDC for more ETH and then re-pay the amount of ETH he borrowed

This is very inconvenient for Mike and it could cause him to ditch blockchain and go back to fiat-only payments. Let’s help Mike to solve the problem and stay with blockchain.

The solution

Meta-transactions gaining popularity nowerdays. The reason for this is cause they gas-less. Gas fees could be a barrier for many users. Wallet with zero balance is still able to sign messages and those messages are proof of ownership and could be used to interact with smart-contracts.

USDC token contract supports permit function that takes EIP-712 signature as a parameter to approve spending. That means that token holder is able to sign spending approval off-chain and let someone else to execute permit on chain and pay for gas for this call. Let’s use this feature for gas-less purchase of ETH

The workflow

System design diagram

Mike has USDC and zero ETH but someone has ETH and willing to sell it to Mike. Let’s call Mike a Customer and seller a Gas Provider.

Gas provider should have motivation to perform the trade — he should earn some reward. Let Customer to decide the value of reward, but he should keep in mind that it should exceed the cost of transaction that Gas Provider will sent to blockchain. Let’s say if transfer ETH currently cost in average $5 in gas fees then Customer should set a reward higher than $5 otherwise no one will be willing to execute his order.

To make an order customer should prepare a signed EIP-712 message for spending approval and define a reward he is willing to pay. Customer should approve spending not for the Gas Provider (otherwise he could be screwed by dishonest Gas Providers) but to the trusted gateway. Thrusted gateway is a smart contract — let’s call it Gas Broker. This contract is trusted cause it is open-source and immutable.

The purpose of Gas Broker contract is to be an arbiter in trades. It will make sure the trade is fare by checking how much ETH Gas Provider sends in exchange for USDC. It takes in account ETH price provided by Price Oracle and reward provided by Customer. So initially tokens and ETH goes to Gas Broker — it checks if the rates are fare then transaction is settled, otherwise it will be reverted. To prevent Gas Provider from manipulating the value of reward the reward should be provided inside the message that is signed by Customer.

As we can see Customer have to provide 2 signed messages — one is spending approval for Gas Broker and another contains the value of reward he offers to Gas provider. These 2 signatures alongside with amount of tokens and customer wallet address and deadline will be published in Order-book.

Gas Providers can explore Order-book, pick any order that is profitable and send transaction to Gas Broker with corresponding amount of ETH. It is possible that one order will be picked by multiple Gas Providers but because of nature of blockchain only one transaction will be settled — Gas Stations will have to compete for orders by choosing optimal fee. Gas Broker will check ETH price using Price Oracle, check the validity of signatures in both messages, check the amount of ETH provided by Gas provider with transaction by formula: (value — reward) / ethPrice and if everything correct then it will call permit on USDC token contract, transfer USDC to Gas Provider and send ETH to Customer. Once transaction is mined Customer will get ETH and Gas provider will get tokens.

Development plan

In the following parts I will implement the whole infrastructure:

  • Gas Broker smart-contract
  • Backend API for receiving orders from Customer
  • UI for making orders using MetaMask
  • UI for browsing Order-book
  • UI for fulfilling orders using MetaMask
  • The example of Gas Provider bot that will automatically pick orders based on profitability and execute them on-chain

Once the project is completed, there will be a web-page where anyone could request ETH by submitting order — no gas-fees, just have to sign 2 messages, provide ETH choosing one of published orders or connect bot using API. This will allow Mike to exchange USDC for ETH in a quick, secure and gas-less way without bothering his friend. And this will also let anyone who has some ETH to earn rewards by helping Mike and other new crypto-users.

--

--

Alexander Koval
Coinmonks

I'm full-stack web3.0 developer, dedicated to bring more justice in this world by adopting blockchain technologies