Multi Signature
Multi Signature (multisig) allows multiple users to sign a transaction before it is broadcasted to the network.
This ensures that no single user can execute a transaction unilaterally, adding an extra layer of security and trust.
Multisig accounts are essential in environments where assets are managed collectively, such as corporate treasuries or joint accounts.
In this tutorial, we will explore how to create and manage multisignature accounts, proposals, and execute them using the InitiaJS
library.
Create Multisig Accounts
Creating a multisig account is the first step in setting up a multi-approval system.
This account will require a predefined number of approvals (threshold) to execute transactions.
account
: The signer creating the multisig account.name
: A name to generate a unique multisig address.members
: A vector of addresses that will be members of the multisig account.threshold
: The minimum number of approvals required to execute a transaction.
Create a Proposal
Once the multisig account is established, members can create proposals for actions that require collective approval.
A proposal outlines the intended transaction or changes that need to be approved by the members.
multisig_addr
: The address of the multisig account where the proposal is created.module_address_list
: module addresses to be executed in the proposal.module_name_list
: module names to be executed in the proposal.function_name_list
: function names to be executed in the proposal.type_args_list
: Type arguments required for the functions.args_list
: Arguments for the functions.expiry_duration
: Optional expiration duration for the proposal.
In this example, we will create two proposals.
The first proposal sends tokens using the 0x1::cosmos::stargate
function, and the second proposal sends tokens using the 0x1::coin::transfer
function.
Vote Proposal
Members of the multisig account can vote on active proposals. Each member can choose to approve or reject a proposal.
The proposal passes once it receives the minimum number of approvals defined by the threshold.
Execute Proposal
After a proposal has received enough approvals, it can be executed.
This action carries out the transactions or changes specified in the proposal.
multisig_addr
: The address of the multisig account where the proposal is created.proposal_id
: The ID of the approved proposal to execute.
Full Example
Below are two summarized examples demonstrating how to create a multisig account, create a proposal, vote on it, and execute it using InitiaJS
:
- Token Transfer: Focuses on creating and executing a proposal that transfers tokens from the multisig account.
- Move Module Upgrade: Showcases how to propose and publish (or upgrade) a Move module via a multisig proposal.
Was this page helpful?