Modifying a multisig account min approval

This guide will show you how to increase and decrease the minimum number of signatures needed to execute a multisig transaction.

Use case

Imagine that Alice and Bob are cosignatories of a 1-of-2 multisig account. This means that at least one of their account’s signatures is required to authorize multisig transactions. In other words, we can say that the minApproval property of the multisig is currently set to 1.

In this case, we want to make both cosignatories required, shifting to a 2-of-2 multisig instead. To achieve this, we will be increasing minApproval by one unit.

../../_images/multisig-2-of-2.png

2-of-2 multisig account example

Prerequisites

Method #01: Using the Desktop Wallet

  1. Log in to an account that is a cosignatory (Alice or Bob) of the account you want to modify.

  2. Click on the “Multisig” tab on the left-side of the wallet.

  3. Select the multisig wallet you want to modify from the dropdown menu from the top field. This will convert the “Operation Type” to “Modifying account multisig properties”.

../../_images/modify-multisig-1.gif
  1. Select the new “Min. Approval” number. In this case, we want to change it to “2”. Click “Send”. Review the information on the popup. Enter your wallet password and click “Confirm”.

../../_images/modify-multisig-2.gif
  1. If the multisig account has the “minimum approval” set to a number greater than 1, log in to another cosignatory account and cosign the transaction. Repeat this step until the minimum approval number is satisfied.

../../_images/add-signer-2.gif
  1. Once the Aggregate Transaction is confirmed, you can check its new properties in the “Multisig” menu.

../../_images/modify-multisig-3.png

Method #02: Using the SDK

One of the cosignatory accounts, for example Alice’s, will announce a MultisigAccountModificationTransaction to increase minApprovalDelta.

  1. Open a new file. Then, define Alice’s account public key and the multisig account private key into new variables.

// replace with network type
const networkType = NetworkType.TEST_NET;
// replace with cosignatory private key
const cosignatoryPrivateKey =
  '1111111111111111111111111111111111111111111111111111111111111111';
const cosignatoryAccount = Account.createFromPrivateKey(
  cosignatoryPrivateKey,
  networkType,
);
// replace with multisig account private key
const multisigAccountPublicKey =
  '3A537D5A1AF51158C42F80A199BB58351DBF3253C4A6A1B7BD1014682FB595EA';
const multisigAccount = PublicAccount.createFromPublicKey(
  multisigAccountPublicKey,
  networkType,
);
// replace with network type
const networkType = symbol_sdk_1.NetworkType.TEST_NET;
// replace with cosignatory private key
const cosignatoryPrivateKey =
  '1111111111111111111111111111111111111111111111111111111111111111';
const cosignatoryAccount = symbol_sdk_1.Account.createFromPrivateKey(
  cosignatoryPrivateKey,
  networkType,
);
// replace with multisig account private key
const multisigAccountPublicKey =
  '3A537D5A1AF51158C42F80A199BB58351DBF3253C4A6A1B7BD1014682FB595EA';
const multisigAccount = symbol_sdk_1.PublicAccount.createFromPublicKey(
  multisigAccountPublicKey,
  networkType,
);
  1. Define a MultisigAccountModificationTransaction to increase the minAprovalDelta by one unit.

const multisigAccountModificationTransaction = MultisigAccountModificationTransaction.create(
  Deadline.create(epochAdjustment),
  1,
  0,
  [],
  [],
  networkType,
);
const multisigAccountModificationTransaction = symbol_sdk_1.MultisigAccountModificationTransaction.create(
  symbol_sdk_1.Deadline.create(epochAdjustment),
  1,
  0,
  [],
  [],
  networkType,
);

Note

If you want to decrease the minApproval property, set minApprovalDelta with a negative value. For example, to reduce the number of required signers by one unit, you should set minApprovalDelta to -1.

  1. Wrap the MultisigAccountModificationTransaction in an AggregateTransaction, attaching the multisig public key as the signer.

An AggregateTransaction is complete if, before announcing it to the network, all required cosignatories have signed it. If valid, it will be included in a block. As only one cosignature is required (1-of-2), Alice can sign define the aggregate as complete, sign the transaction, and announce it to the network.

const aggregateTransaction = AggregateTransaction.createComplete(
  Deadline.create(epochAdjustment),
  [multisigAccountModificationTransaction.toAggregate(multisigAccount)],
  networkType,
  [],
  UInt64.fromUint(2000000),
);

// replace with meta.networkGenerationHash (nodeUrl + '/node/info')
const networkGenerationHash =
  '1DFB2FAA9E7F054168B0C5FCB84F4DEB62CC2B4D317D861F3168D161F54EA78B';
const signedTransaction = cosignatoryAccount.sign(
  aggregateTransaction,
  networkGenerationHash,
);
// replace with node endpoint
const nodeUrl = 'NODE_URL';
const repositoryFactory = new RepositoryFactoryHttp(nodeUrl);
const transactionHttp = repositoryFactory.createTransactionRepository();

transactionHttp.announce(signedTransaction).subscribe(
  (x) => console.log(x),
  (err) => console.error(err),
);
const aggregateTransaction = symbol_sdk_1.AggregateTransaction.createComplete(
  symbol_sdk_1.Deadline.create(epochAdjustment),
  [multisigAccountModificationTransaction.toAggregate(multisigAccount)],
  networkType,
  [],
  symbol_sdk_1.UInt64.fromUint(2000000),
);
// replace with meta.networkGenerationHash (nodeUrl + '/node/info')
const networkGenerationHash =
  '1DFB2FAA9E7F054168B0C5FCB84F4DEB62CC2B4D317D861F3168D161F54EA78B';
const signedTransaction = cosignatoryAccount.sign(
  aggregateTransaction,
  networkGenerationHash,
);
// replace with node endpoint
const nodeUrl = 'NODE_URL';
const repositoryFactory = new symbol_sdk_1.RepositoryFactoryHttp(nodeUrl);
const transactionHttp = repositoryFactory.createTransactionRepository();
transactionHttp.announce(signedTransaction).subscribe(
  (x) => console.log(x),
  (err) => console.error(err),
);
  1. Once confirmed, the minApproval value of the multisig will be set to 2, having our 2-of-2 multisig.

Note

If more than one cosignature is required to announce the transaction (e.g., the multisig is a 2-of-2 account), the transaction must be defined as aggregate bonded, and all other required multisig participants should cosign it in order to be confirmed. Follow the next guide to announce aggregate bonded transactions involving a multisig account.

Follow the next guide to add a new signer to the multisig account.