This is the package for the Squads v4 Typescript SDK.
Add the SDK to your project with npm:
npm i @sqds/multisig
or yarn:
yarn add @sqds/multisig
First, get the multisig account address:
import * as multisig from "@sqds/multisig";
const {
Multisig
} = multisig.accounts;
const [multisigPda] = multisig.getMultisigPda({
createKey,
});
/// or define it directly
const multisigPda = new PublicKey("<multisig key>");
Then get the multisig account info:
const multisigAccount = await Multisig.fromAccountAddress(
connection,
multisigPda
);
// Log out the multisig's members
console.log("Members", multisigAccount.members);
Once you fetch your multisig, fetch the vault account:
const [vaultPda] = multisig.getVaultPda({
multisigPda,
index: 0,
});
From here, you can create your first vault transaction:
const transactionIndex = 1n;
const transferInstruction = SystemProgram.transfer(
// The transfer is being signed from the Squads Vault, that is why we use the VaultPda
vaultPda,
to.publicKey,
1 * LAMPORTS_PER_SOL
);
// Here we are adding all the instructions that we want to be executed in our transaction
const testTransferMessage = new TransactionMessage({
payerKey: vaultPda,
recentBlockhash: (await connection.getLatestBlockhash()).blockhash,
instructions: [transferInstruction],
});
await multisig.rpc.vaultTransactionCreate({
connection,
feePayer,
multisigPda,
transactionIndex,
creator: feePayer.publicKey,
vaultIndex: 0,
ephemeralSigners: 0,
transactionMessage: testTransferMessage,
});
Check our documentation for more information on instruction types and ancillary features.