Biconomy SDK

Create Custom Transaction Batch

In order to create a batch of transactions, just create Transaction Request array and push individual transaction requests (destination contract and encoded data for method to be called)
In the order of atomic execution, you can keep adding transactions to a batch array like the below example.
Also let's talk about network switching...
import {
} from "@biconomy/core-types";
import SmartAccount from "@biconomy/smart-account";
// Get the EOA provider for choice of your wallet which manahes your signer
const { provider, address } = useWeb3AuthContext();
const walletProvider = new ethers.providers.Web3Provider(provider);
// Initialize the Smart Account
let options = {
activeNetworkId: ChainId.GOERLI,
supportedNetworksIds: [ ChainId.GOERLI, ChainId.POLYGON_MAINNET, ChainId.POLYGON_MUMBAI
let smartAccount = new SmartAccount(walletProvider, options);
smartAccount = await smartAccount.init();
Once wallet instance is instantiated, Dapp can choose to make transaction on any of the supported chains other than current active chain.
You can do that in two ways, here is one way. Active switching to different network (for complete smart account API)
// you can change you active chain and make transactions
// Now you active chain has been chaged from GOERLI to ETHEREUM MAINNET
The second way is to just change the chainId in DTO of the method. This will only affect the current action while remaining runs on current active chainId by default.
const txResponse = await smartAccount.
({ chainId: ChainId.MAINNET,
transaction: tx1
When instantiating the wallet instance, GOERLI is currently used as default chainId that means but when making a Transaction you switch chain to polygon or any of the supported EVM chains.
List of Method whose DTO support custom ChainId
1. sendGasLessTransaction(
transactionDto: TransactionDto
): Promise<TransactionResponse>
2. sendGaslessTransactionBatch(
transactionBatchDto: TransactionBatchDto
): Promise<TransactionResponse>
3. getAlltokenBalances(
balancesDto: BalancesDto,
chainId: ChainId = this.#smartAccountConfig.activeNetworkId
): Promise<BalancesResponse>
4. getTotalBalanceInUsd(
balancesDto: BalancesDto,
chainId: ChainId = this.#smartAccountConfig.activeNetworkId
): Promise<UsdBalanceResponse>
5. getSmartAccountsByOwner(
smartAccountByOwnerDto: SmartAccountByOwnerDto
6. getTransactionByAddress(
chainId: number,
address: string
): Promise<SCWTransactionResponse[]>
7. signTransaction(signTransactionDto: SignTransactionDto): Promise<string>
8. sendTransaction(sendTransactionDto: SendTransactionDto): Promise<string>
9. prepareRefundTransaction(
prepareRefundTransactionDto: PrepareRefundTransactionDto
): Promise<FeeQuote[]>
10. prepareRefundTransactionBatch(
prepareRefundTransactionsDto: PrepareRefundTransactionsDto
): Promise<FeeQuote[]>
11. createRefundTransaction(
refundTransactionDto: RefundTransactionDto
): Promise<IWalletTransaction>
12. createTransaction(transactionDto: TransactionDto): Promise<IWalletTransaction>
13. createTransactionBatch(
transactionBatchDto: TransactionBatchDto
): Promise<IWalletTransaction>
14. createRefundTransactionBatch(
refundTransactionBatchDto: RefundTransactionBatchDto
): Promise<IWalletTransaction>
15. getAddress(
addressForCounterFactualWalletDto: AddressForCounterFactualWalletDto