DEV Community

Cover image for What are Batch Transactions on the Blockchain Network?
mohamad najafi
mohamad najafi

Posted on

What are Batch Transactions on the Blockchain Network?

Today, while I was browsing through incoming transactions for Payment4 merchants, I stumbled upon a transaction that had been conducted on the Ethereum network using USDT. Surprisingly, the system couldn’t recognize it. It was quite unusual, with less than a 1% chance of such an occurrence. So, I decided to investigate further and discovered that the transaction was, in fact, a Batch Transaction. I never imagined that anyone would use this type of transaction in the system. However, this kind of transaction is quite common among large exchanges (the sending exchange was Coinbase 😎).

So, what’s the story behind Batch Transactions?

I’ll try to explain it in a simple and concise manner.
Digital exchanges typically handle user withdrawal requests in a way that minimizes network fees. If they were to send each withdrawal individually on the network, the total network fees for all transactions would be quite high, making it impractical for them. Therefore, they never send withdrawals individually. Instead, they create a smart contract responsible for distributing the total withdrawal amount (such smart contracts are usually custom-built for each network). They then send the total amount requested by users (for example, 2000 USDT in ERC20) along with the wallet addresses of all the requesting users and each user’s share to the smart contract. From there, the smart contract takes over, automatically distributing the requested amounts to the respective recipients on the network.

What are the advantages of Batch Transactions?

One of the biggest advantages is that it significantly reduces network fees. For instance, if 10 transactions are processed within a single Batch Transaction, the total network fee can be reduced by approximately 30%. However, this 30% is an estimate and depends entirely on the network’s condition, the number of transactions, and several other parameters.

Decoding this type of transaction on the network is somewhat more complicated than other transactions. The reason is that the entire batch of transactions has a single hash on the network, which means all Batch Transactions are considered as one. To get the details of each transaction, such as the final recipient’s address, the token address used in the transaction, and the transferred token amount, you need to extract this information from the transaction’s receipt log and the transaction input data.

A while ago, when I was working with a team on a Launchpad project, I became familiar with these types of transactions, known as Batch Transactions.

If you’re interested in working with these types of smart contracts and learning how to use them, I recommend studying the sample available on GitHub. Their structure and mechanism are generally similar, though there may be differences in the specifics of each network.

https://github.com/xdevguild/sc-multi-sender-rs

Top comments (0)