Batches allow you to approve, reject, cancel, or execute multiple transactions with a single action.
When working with batches, you can follow this general procedure:
Create a batch
Create a proposal as a draft
Add transactions to the batch
Activate the proposal
Vote on the proposal
Execute the proposal
Example
import*as multisig from"@sqds/multisig";import { Connection, PublicKey } from"@solana/web3.js"asyncfunctionmain(member:PublicKey) {// Cluster Connectionconstconnection=newConnection("<your rpc url>");// If you've saved your createKey, you can define it as a static PublicKeyconstcreateKey=newPublicKey("<your createkey>")// Derive the multisig PDAconst [multisigPda] =multisig.getMultisigPda({ createKey, });// or// const multisigPda = new PublicKey("<your multisig key>");// Get deserialized multisig account infoconstmultisigInfo=awaitmultisig.accounts.Multisig.fromAccountAddress( connection, multisigPda );// Get the current transaction indexconsttransactionIndex=Number(multisigInfo.transactionIndex);// or, if this is tied to your first transaction// const transactionIndex = 1n;// Create the batch, which we can add transactions toconstbatchCreateIx=awaitmultisig.instructions.batchCreate({ batchIndex: transactionIndex, creator: member, multisigPda, vaultIndex:0, memo:"Creating a batch", });// Create the proposal for voting on the transactionsconstproposalCreateIx=awaitmultisig.instructions.proposalCreate({ multisigPda,// Created with the same index as the batch transactionIndex: transactionIndex, creator: member,// Proposal is created as a draft isDraft:true, });}
Notes
Batches are for coupling multiple vault transactions under one proposal
They have their own transactionIndex context, starting at 1