Let’s get rid of transactions for approving/revoking tokens

Even as a DEFI beginner, you may already find SEP20 token’s approving transactions are annoying: if you want to add liquidity to the CATS/FLEXUSD pool, you must send one transaction for approving CATS and another transaction for approving FLEXUSD, before you can finally deposit your CATS and FLEXUSD tokens into a DEX pool.

When you get more knowledge and experience on the risks and exploits in the DEFI world, you are aware that approving tokens to a contract is a dangerous operation. And then you find some utilities such as revoke.cash and approval-tracker to revoke your allowance to the contracts, which are annoying tasks, too.

When a cautious DEFI user interacts with a suspicious contract, she follows such a process: approve the necessary token allowances, call the suspicious contract, and finally revoke the remained allowances (if any). It is very tedious that this process needs at least three transactions (more transactions are needed when more tokens need to be approved). But it is worthwhile because she never worries about the approved allowances after this process.

You may wonder: why can’t all these tasks be automated? People just click the wallet once and it will automatically send the transactions one by one. Well, even with such a feature, users still have to wait for several transactions to be broadcasted and then executed on-chain. The delay and waiting are still annoying.

A better solution is making the chain itself add a new feature to help out. And it’s just what smartBCH is going to do: a feature named “EOA Delegator” is planned to be added in the next hardfork upgrade, i.e., the sha-gate upgrade.

EOA is short for Externally Owned Account, i.e., an account controlled by a private key. EOA delegators are smart contracts to which EOAs can delegatecall.

What is delegatecall? It means that whatever the bytecode in an EOA delegator does, it acts as if the EOA (instead of the contract) does it. For example, if the bytecode calls a SEP20 tokens approve method, the result is the same as the EOA calls the approve method and sets the allowance for some smart contract to spend from the EOA's balance.

Currently, no EVM-compatible chain allows an EOA to send a transaction that delegatecalls a smart contract. This will be changed in smartBCH’s next upgrade. After that, smartBCH will take a specialized smart contract as the EOA delegator. Whenever they are used as the target of a transaction (called by EOAs), they execute as if they are delegatecalled.

The EOA delegator has been already opensourced. They help EOA to automate such a process: 1) approve one or more tokens; 2) call a contract to do the desired job; 3) revoke any remained allowance. With EOA delegators, you can act as a cautious DEFI user easily. We welcome comments and reviews on them.

EOA delegator’s technical detail is described in SEP103. If you have any suggestions or ideas on it, please reach out to us through telegram, GitHub, or email.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store

Maximize throughput of EVM & Web3 on a sidechain of Bitcoin Cash