Skip to main content

Generate a multisig signature

The Smart Accounts KitSmart Accounts Kit Toolkit for creating, managing, and interacting with MetaMask Smart Accounts, delegations, and Advanced Permissions. supports Multisig smart accounts, allowing you to add multiple EOAExternally owned account (EOA) A private-key-controlled account with no built-in programmable execution logic. signersSigner An account that can sign transactions for a smart account. with a configurable execution threshold. When the threshold is greater than 1, you can collect signatures from the required signers and use the aggregateSignature function to combine them into a single aggregated signature.

Prerequisites

Generate a multisig signature

The following example configures a Multisig smart account with two different signers: Alice and Bob. The account has a threshold of 2, meaning that signatures from both parties are required for any execution.

import { 
bundlerClient,
aliceSmartAccount,
bobSmartAccount,
aliceAccount,
bobAccount,
} from "./config.ts";
import { aggregateSignature } from "@metamask/smart-accounts-kit";

const userOperation = await bundlerClient.prepareUserOperation({
account: aliceSmartAccount,
calls: [
{
target: zeroAddress,
value: 0n,
data: "0x",
}
]
});

const aliceSignature = await aliceSmartAccount.signUserOperation(userOperation);
const bobSignature = await bobSmartAccount.signUserOperation(userOperation);

const aggregatedSignature = aggregateSignature({
signatures: [{
signer: aliceAccount.address,
signature: aliceSignature,
type: "ECDSA",
}, {
signer: bobAccount.address,
signature: bobSignature,
type: "ECDSA",
}],
});