Modular Account with Multisig Plugin • Getting started
1. Create a Multisig Account Client
Initialize a Multisig Modular Account client and set the n
accounts as signers.
It is recommended to use the createMultisigAccountAlchemyClient
directly to create new accounts with multi-sig ownership, rather than extending the Modular Account client.
If you have an existing Modular Account (which has multi-owner plugin by default), please see details here for installing the plugin before proceeding.
3. Propose a User Operation
To propose a new user operation for review by the multisig signers, you will use the proposeUserOperation
method. This estimates gas, constructs the user operation struct, and if gasManagerConfig
is used then it attempts to use a paymaster. Lastly, a signature is generated with the pre-provided signer.
4. Get the threshold signatures
Next, you have to collect the next k-2 signatures, excluding the first signature which you already provided and the last signature which we’ll deal with in step 5 when we send the user operation. Each member of the multisig can sign with the signMultisigUserOperation
method.
5. Send the User Operation
After collecting k-1 signatures, you’re ready to collect the last signature and send the user operation. This is done with the sendUserOperation
method. sendUserOperation
also formats this aggregated signature, sorting its parts in ascending order by owner address as expected by the Multisig Plugin smart contract.
By default, we use the variable gas feature in the Multisig Plugin smart contract. For this, we need userOpSignatureType
to be set to “ACTUAL”. If you do not wish to use this feature, gas overrides should be passed in sendUserOperation
, and userOpSignatureType
should be set to “UPPERLIMIT”.
Conclusion
That’s it! You’ve initialized a modular account with three multisig members, proposed a user operation, collected the necessary signatures, and sent the user operation to the bundler.
For more info, check out the technical details of the multisig plugin.