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 Multisig

Create a Squads multisig

Be sure to use multisigCreateV2, rather than the deprecated multisigCreate

This instruction will create a Multisig account with the necessary fields. This instruction requires that both the creator of the multisig, and the createKey be signers.

Example

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

// Defines permissions enum
const { Permission, Permissions } = multisig.types;

async function main() {
    // Cluster Connection
    // Required argument if you use the .rpc method
    const connection = new Connection("< your rpc here >");
    
    // Random Public Key that will be used to derive a multisig PDA
    // This will need to be a signer on the transaction
    const createKey = Keypair.generate().publicKey;
    
    // Creator should be a Keypair or a Wallet Adapter wallet
    const creator = Keypair.generate();
    
    // Derive the multisig PDA
    const [multisigPda] = multisig.getMultisigPda({
        createKey,
    });
    
    const programConfigPda = multisig.getProgramConfigPda({})[0];

    const programConfig =
        await multisig.accounts.ProgramConfig.fromAccountAddress(
          connection,
          programConfigPda
        );

    const configTreasury = programConfig.treasury;
    
    const ix = await multisig.instructions.multisigCreateV2({
        // Must sign the transaction, unless the .rpc method is used.
        createKey: createKey.publicKey,
        // The creator & fee payer
        creator: creator.publicKey,
        // The PDA of the multisig you are creating, derived by a random PublicKey
        multisigPda,
        // Here the config authority will be the system program
        configAuthority: null,
        // Create without any time-lock
        timeLock: 0,
        // List of the members to add to the multisig
        members: [{
                // Members Public Key
                key: creator.publicKey,
                // Granted Proposer, Voter, and Executor permissions
                permissions: Permissions.all(),
            },
            {
                key: secondMember.publicKey,
                // Member can only add votes to proposed transactions
                permissions: Permissions.fromPermissions([Permission.Vote]),
            },
        ],
        // This means that there needs to be 2 votes for a transaction proposal to be approved
        threshold: 2,
        // This is for the program config treasury account
        treasury: configTreasury,
        // Rent reclaim account
        rentCollector: null
    });
    
    console.log("Multisig created: ", signature)
}

Notes

  • Must specify permissions upfront for each member

  • Only specify a configAuthority if you want one admin key to be able to override all config

  • createKey must be a signer if using methods other than .rpc

PreviousInstructionsNextCreate Config Transaction

Last updated 7 months ago