Squads Docs
Development
Development
  • Introduction
    • What is Squads Protocol
    • Use Cases
    • Quickstart
  • Typescript
    • Overview
    • Instructions
      • Create Multisig
      • Create Config Transaction
      • Create Vault Transaction
      • Create Proposal
      • Approve Proposal
      • Reject Proposal
      • Cancel Proposal
      • Execute Config Transaction
      • Execute Vault Transaction
      • Create Batch
      • Add To Batch
      • Close Vault Transaction Account
      • Controlled Multisig Instructions
        • Add Member
        • Remove Member
        • Set Rent Collector
        • Add spending limit
        • Remove Spending Limit
    • Accounts
      • Multisig
      • Vault
      • Transactions
      • Proposal
      • Batch
  • Reference
    • Accounts
    • Permissions
    • Spending Limits
    • Time-locks
    • SDKs
    • Controlled Multisigs
  • API
    • Vault Check
  • CLI
    • Installation
    • Commands
  • Get Support
    • We're here to help
  • Other
    • Migrating from MultisigCreate v1 to v2
    • Squads Actions and Blinks
Powered by GitBook
On this page
  • Example
  • Notes
  1. Typescript
  2. Instructions

Create Batch

Creating a batch for coupling transactions

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:

  1. Create a batch

  2. Create a proposal as a draft

  3. Add transactions to the batch

  4. Activate the proposal

  5. Vote on the proposal

  6. Execute the proposal

Example

import * as multisig from "@sqds/multisig";
import { Connection, PublicKey } from "@solana/web3.js"

async function main(member: PublicKey) {
    // Cluster Connection
    const connection = new Connection("<your rpc url>");
    
    // If you've saved your createKey, you can define it as a static PublicKey
    const createKey = new PublicKey("<your createkey>")
    
    // Derive the multisig PDA
    const [multisigPda] = multisig.getMultisigPda({
        createKey,
    });
    // or
    // const multisigPda = new PublicKey("<your multisig key>");
    
    // Get deserialized multisig account info
    const multisigInfo = await multisig.accounts.Multisig.fromAccountAddress(
      connection,
      multisigPda
    );

    // Get the current transaction index
    const transactionIndex = Number(multisigInfo.transactionIndex);
    // or, if this is tied to your first transaction
    // const transactionIndex = 1n;
    
    // Create the batch, which we can add transactions to
    const batchCreateIx = await multisig.instructions.batchCreate({
        batchIndex: transactionIndex,
        creator: member,
        multisigPda,
        vaultIndex: 0,
        memo: "Creating a batch",
    });
    
    // Create the proposal for voting on the transactions
    const proposalCreateIx = await multisig.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

PreviousExecute Vault TransactionNextAdd To Batch

Last updated 8 months ago