Batch Transactions

You can also do batch transactions through the Bastion SDK.

Some great use cases for batch transactions are airdrops, transferring tokens to multiple addresses, 'approve and transferFrom' in the same transaction.

const bastion = new Bastion();
const bastionConnect = await bastion.bastionConnect;

const CONFIG = {
	chainId: <chain_id>, // optional
	privateKey: <your_private_key>, //optional
	rpcUrl: <RPC_URL>, //optional
	apiKey: <your_api_key> //required
};			
bastionConnect.init(<your_web3Provider>, CONFIG);

// ... Other Transaction and contract details

const transfer1 = {
	to: contractAddress,
	value: 0,
	data: erc721Contract.interface.encodeFunctionData("transferFrom", [fromAddress, toAddress, 46]),
};

const transfer2 = {
	to: contractAddress,
	value: 0,
	data: erc721Contract.interface.encodeFunctionData("transferFrom", [fromAddress, toAddress, 47]),
};

const transactionArray = [transfer1, transfer2];
const res = await bastionConnect.executeBatch(transactionArray);

Last updated