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

Last updated