Execute Vault Transaction

Execute an approved vault transaction

Executing a vault transaction will take all of the instructions saved in the message field of the corresponding Vault Transaction account, and atomically execute them via CPI. This requires that the Proposal accounts for the transaction is of Approved status, and the member running the instruction has Executor permissions.

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;
    
    const ix = await multisig.instructions.vaultTransactionExecute({
        multisigPda,
        transactionIndex,
        // Member must have "Executor" permissions
        member: member,
    });
}

Notes

  • Member must have "Executor" permissions

  • Requires the corresponding proposal to be of Approved status

  • Will execute each instruction via CPI, requiring the instructions to be valid

    • Since this is an asynchronous process, some instructions may become stale due to external program checks like slippage.

Last updated