Introducing Batched Transactions on Authereum

Improving Speed and Efficiency on Ethereum

Shane Fontaine
Authereum
5 min readNov 7, 2019

--

Wallets on Ethereum are evolving from simple externally owned accounts (EOAs) to contract-based accounts because of the advantages and features that these types of accounts enable. One such feature that is only available for contract-based accounts (CBA) is batched transactions. Batched transactions allow users of the wallet to perform multiple transactions in one single on-chain transaction.

There are a number of advantages to batching many transactions into a single transaction. One advantage is that of efficiency — batched transactions save both in cost and time. Each transaction on Ethereum costs 21,000 gas as a base fee. A total gas savings of 189,000 gas can be achieved if a user batches 10 transactions at once. Additionally, a user can save time when attempting to send sequential transactions.

Batched transactions also allow for an enhanced user experience. An obvious example is removing the need to call both approve and transferFrom on an ERC20 token in two separate transactions. This leads to dapp developers designing their dapps with a more familiar web 2.0 feel — no need to explain the intricacies of the blockchain and perform all required steps in a single button.

To summarize the advantages of of batched transactions before diving in, see the bullet points below:

  • Execute multiple transactions in a single, on-chain transaction
  • Simplify UX and improve usability by abstracting crypto terms away from users
  • Design your app in a seamless way with a web 2.0 feel

Improved Usability

Stepping away from the realm of cryptocurrency for a minute, we can compare batched transactions to more traditional experiences in order to better understand the advantages. Amazon introduced 1-click purchases in 1999. In doing so, they achieved a similar effect as batched transactions — they improved usability by abstracting away unnecessary steps for a user. In Amazon’s case, this abstraction consists of going to your shopping cart, adding or confirming your address and payment method, and finally approving the transaction. 1-click purchase allowed Amazon to abstract away all of these repetitive steps in order to achieve an incredible user experience. Batched transactions do the same for Ethereum interactions.

Ethereum and blockchains in general are notoriously difficult to use. Contract-based accounts, and more specifically batched transactions, will help alleviate this difficulty for both new and experienced users.

Users can now experience dapps without ever learning the intricacies of the blockchain or understanding exactly what is going on under the hood. Batched transactions allow dapp designers to abstract many Ethereum terms away from users and provide a seamless experience for all.

If Uniswap used batched transactions, they could remove the “Unlock” button

The approve and transferFrom are common parlance for those of us who have been in this space for a few years. The idea of two transactions to send tokens, however, is foreign to new users and is inefficient for all. Batched transactions allow both of these functions to be called in a single, on-chain transaction.

This feature also allows dapp developers to design their dapps with a more natural feeling and, in some cases, completely remove the need to teach a user about the underlying mechanisms. Decentralized exchanges, for example, could allow their users to convert ETH to WETH, approve a WETH transfer, and trade WETH for some other asset, all in a single transaction! Better yet, this single transaction can all be accomplished at the click of only one button on the dapp.

There are other, more complex applications that may benefit even more from this feature. DAOStack, for example, sometimes requires up to five transactions for a user to perform a single action. Dapps that have these high throughput requirements may benefit greatly from batched transactions.

Implementation

Smart contract creators sometimes ask if they need to modify their existing contracts in order to be able to access batched transactions. The answer is no!

Contract based accounts who implement batched transactions can do so in a way that requires no changes to the contracts they interact with. In it’s simplest form, a batched transaction implementation looks as follows:

The transaction that calls sendBatchedTransaction must include arrays of transaction data to loop through. The contract-based account then loops through each item of the array and performs a call to the destination.

When implementing this, one must consider a potential failed transaction. A well designed implementation will check for the return status of the call and throw the entire transaction if any of the call s were to fail. With this implementation, the transaction would fail atomically (all or nothing) and save users from unintended consequences, such as approved tokens that go unspent.

EIP 1193

EIP 1193 formalizes an Ethereum Provider JavaScript API for consistency across clients and applications. It is an attempt to standardize the Ethereum providers so that dapp developers can more easily integrate their favorite provider. Many members of the provider community gathered at Devcon V to discuss this standard.

Batched transactions as a part of this standard was discussed during this conversation. While the standard is currently focused on remaining minimal, a batched transaction API was considered for inclusion either later in the lifetime of this EIP, or in an EIP that extends 1193.

Standardizing this API will make it even easier for dapp developers to implement this feature.

Conclusion

Batched transactions unlock world of efficiency and continuity on Ethereum. Coupling this feature with others offered by contract-based accounts will unlock a seamless crypto experience for users of all experience levels. Learn more about the benefits of contract based accounts below.

Feel free to reach out if you want help designing your dapp with these features in mind!

Follow us on twitter @authereum for updates and sign up for the Authereum mainnet waitlist.

--

--