Batch Transactions
Base·Sun, Nov 9, 2025, 12:00 AM
Learn how to Batch Transactions with Base Account 00:00 Intro and Smart Contract 01:56 UX demo 05:10 Diving into the code Demo: https://github.com/base/demos/tree/master/base-account/base-account-wagmi-template Contract and code: https://repo.sourcify.dev/84532/0x82039e7C37D7aAc98D0F4d0A762F4E0d8c8DC273 Guide: https://docs.base.org/base-account/improve-ux/batch-transactions These workshops are run by our internal Developer Relations Team, designed to teach you best practices coming from real-world Base experience. #OnchainAppInsights #web3 #accountabstraction #erc4337 #onchain #onchainApps #gasless #base #basechain #coinbasewallet #crypto #web3 #apps #blockchain
Transcript
Hi everyone and welcome to a new episode of this base account series and today we will be talking about batch transactions. So as you know with base account being a smart wallet or you know a smart account uh you can batch transactions you can use EIP5792 wallet send calls. This is the RPC method to batch transactions. And today we will see how you can do that both with base account SDK and also using Wagmei. So for that I have a demo going on deployed a small you know smart contract here to to show you how this works.
But basically as you know if you have used an EOA before wallet extension or something like that you know that if you go on unis swap on arrum you know minting pages you have to approve your you your sorry approve your ERC20 and then uh you get to mint your NFT or you get to make the swap. That's no longer necessary when it comes to base account or smart accounts. And so how does that happen? Before I dive into the user experience, I want to show you the little smart contract that I built. So, this is a very simple NFT contract.
Uh, it's uh a simple ERC 721 that I got from Open Zeppelin. Shout out to Open Zeppelin for the great work they do. And we have a mint function. So, very simple mint function that requires a small amount of UTC. Uh, this is not 100 USDC by the way.
This is I think a tenth of a cent of UTC. uh and to learn about that you can take a look at the decimals of USDT Google that or ask AI about it and then we have an internal M function that I call so very simple M function uh the only difference here is that it requires a little bit of USDC I'm not even doing any requirements anything I'm hard coding the USDC here the idea here is just to show you something that works and so how does this work from a user perspective as you can see here and we'll sign in uh so I deployed by the way I deployed this contract contia. I have an address here. The contract uh you know anyone can go ahead and mint from it. Um it's completely um yeah it's open for anyone.
So as you can see there's no restrictions here in the function. So um I will put a very a much smaller number for an approval of USDC. So I think we need here you know a tenth of a cent. So I put a tenth of a sense. Again, I would recommend that you ask your users uh to approve just the exact amount that they need to to to make the transaction.
So, in this case, we need a tenth of a scent to mince this NFT. I'm going to put a tenth of a scent. I'm changing the token ID. Again, your users should not be the ones choosing the approval amount and the token ID. And this also is a call out for stopping using elimited approvals.
There's no need to use unlimited approvals on base uh gas is cheap. So your users can approve again and then uh with smart accounts and smart wallets, you don't need uh separate approvals. You can batch this transaction. So honestly, there's no need to ask your users to give you a limited approval. It's not secure.
It's not safe. We should stop that. Um we should stop doing that. and and you know, wallets today are showing more and more of these pop-ups or like um um warnings that show you that you know um this is a limited approval and and your users when they see a red warning they're scared and they're not making the transaction. So there's going to be a big drop off rate.
So stop the eliminated approvals and as a matter of fact at base account if you are asking for un limited approvals I think there's a big chance you will get your users will get that um red warning. So uh make sure to stop asking for a limited approval. Closing the the parenthesis here. Moving on to the user experience. And as you can see here uh when I click on approve and mint uh you can see that the transaction will uh mint uh the NFT token ID number two uh and it will take you know uh it will take a tenth of a cent from you and so yeah let's see so this should work and it um and the batch was sent successfully.
Uh, let me see if this actually worked because um I can go on account.base.app and so that's where you track all the activity that you have. So here it is here. Um, and in the activity you can see that I minted an NFT and it doesn't show the USDC that I sent but I think it's offiscated in the same transaction.
Um, yeah, awesome. So, one NFT meant it to me. Um, and if I look on the block explorer, I can probably see more details. So, I can see the um the RC20. If I look in the logs, I can see the uh approve, yeah, the approval event.
So, everything's very cool here. Uh, how does this work? How does this work? Very, very simple. If you're using uh the base account SDK, you can, you know, set up some calls here.
You can take a look at the doc that I will share in the comments. uh below and uh you can just like use wint calls and that works right um I want to show you how I implemented this uh how I implemented this project here and it's basically a simple Wagi project um you know the Wagi config is as simple as it gets just add base account here with the app name and then uh you can see here the batch transaction component. So I have here the ERC20 AI which frankly I could probably remove a lot of the functions here uh because they do have transfer from and transfer which I don't need these functions. So I can simply do do this basically removing the transfer from oh sorry uh the transfer from function and the transfer function that I had here before and just simply keeping the approval function and then I have the ERC SIM number 21 AI which has the mint function. That's about it when it comes to the APIs.
Then I have the handleb transaction function which the first call data is uh approval and the second called the function is a mint and then you know I have capabilities here which is pay master. I'm not using any pay master um functionality here. Uh it's also because all transactions on base supporter so I don't need to do that. But if you're uh building in on base mainet uh you might want to use a pay master service from Coinbase developer platform for example. And then you can use send calls from there's a function actually called it's a hook I think.
Yeah you send calls from Wagmei uh which is basically the same as the RPC method and then you can send the calls batched at the same time and that's about it right that's it that's all you need to do. So, you have no more excuse, no more excuse today to be doing uh a limited ERC20 approvals in your app when you have this technology. And if you're a user and haven't moved to a smart account already, then I would definitely recommend to move to smart account. Uh it makes your life much easier as a user as well. So, if you have any questions regarding this, happy to chat about it.
I will share uh I will share the link to the sourceify for the contract. I will share the link to this demo uh for you to see the code exactly and I will also share the link to the doc. So if you have any questions drop them below and see you in the next episode.
Automatic transcript — names and jargon may be misspelled.