On-Chain Multisig

With K-of-N multisig authentication, there are a total of N signers for the account, and at least K of those N signatures must be used to authenticate a transaction.

Endless support two method of MultiSig:

  • On-Chain K-of-N multisig

  • Off-Chain K-of-N multisig

Here we describe the operations the On-Chain K-of-N multisig and compares with Off-Chain at the end.

On-Chain K-of-N multisig

Step 1: Pick an SDK

Install your preferred SDK from the below list:

  • TypeScript SDK


Step 2: Run the example

Clone the endless-ts-sdk repo and build it:

git clone https://github.com/endless-labs/endless-ts-sdk.git
cd endless-ts-sdk
pnpm install
pnpm build

Navigate to the Typescript examples directory:

Install the necessary dependencies:

Run the onchain_multisig example:

Process flow

1

First, we will generate accounts for 4 owner accounts and fund them:

2

First we invoke view function 0x1::multisig_account::get_next_multisig_account_address to get multisig account address

The Multisig Account addresss is derived from owner1 account address.

We build a transaction to create a new Multisig Account, via invoke "0x1::multisig_account::create_with_owners()" and append owner2,owner3 the owner of multisig account, set Threshold to 2.

owner1, the signer of transaction of "create multisig account", also is the owner of multisig account.

output like below:

3

Any operation on multisig account is done via interact with "0x1::multisig_account" move module by transaction, eg:

  • create and submit a new transfer EDS multisig transaction

  • vote Appprove for this transaction

  • vote Reject for this transaction

  • execute the transfer EDS multisig transaction

we create a new EDS transfer transaction, from multisig account to recipient, detailed step as below:

  1. generate transaction payload

  2. invoke "0x1::multisig_account::create_transaction" and pass serialized data of payload as input parameter

  3. any owner sign and submit the transaction

create_transaction upload serialized transaction on Endless chain, and get transactionId(value is 1).

owners could refer transactionId to vote.

4

Threshold of multisig is 2, means any transaction, at least 2 owners vote for "Approve" to make tranaction validate. eg:

  • if 2 owners vote for a transcation, one for "Approve", one for "Reject", the transaction execute successfully.

  • if 3 owners vote for a transcation, two for "Approve", one for "Reject", the transaction execute with failure.

simular output as below:

vote count As shown in the code above, owner1 voted in favor, owner3 voted against.

owner2 executed the transaction, effectively casting a vote in favor.

The vote count is 2 in favor, and this transaction can be executed, for the multi-signature governance module

The transfer transaction fails due to multisig account balance is zero.

5

0x1::multisig_account module provide owner management functions as add_owner and remove_owner.

we re-use the same process flow: owner1 voted in favor, owner3 voted against, and owner2 executed the transaction

when execute multisig transaction, we can set transaction payload as new MultiSig(AccountAddress.fromString(multisigAddress)), only specify the multisig account address in the parameters, instead of set transfer traction payload like Step 2. It works because in Step 6. we already upload the AddingOwnerToMultisigAccount to multisig_account module.

specifing the multisig account address in the parameters, indicates that we are specifying the next transaction in the queue within the multisig_account module to be executed, i.e., the AddingOwnerToMultisigAccount transaction.

output as below:

6

We also can modify multisign threshold. At first we set threshold to 2 when create multisign account. now we set threshold to 3

After re-set threshold, we invoke view function num_signatures_required with paramter of multisigAddress to fetch updated threashold

Pros and Cons

On-Chain Multisig

On-Chain multisig implement versatile MultiSig based on Move module, which could expand to support different key schemas in one trasaction, and more expandable features, eg. adding Weight to each account to support Weighted-Threashold multisig.

On-Chain multisig account is created on "0x1::multisig_account" module, and dedicated multisig account. it means we cannot convert any pre-exists account with Ed25519 keypair, into an multisig account.

any k-N multisig transaction, go through K transaction committment, K-1 for seperate approve of each owner, 1 transaction is for any owner execute the transaction. the whole process is gas consumption, compared with Off-Chain multisig.

Off-Chain Multisig

Off-Chain is built on the Endless Account authentication key and off-chain multisig service(Dapp). With well-designed Dapp user interface, users can easily collaborate to sign transactions, while the Dapp handles transaction submission to the Endless network, delivering a smoother operational experience.

Compared to on-chain multisig, off-chain multisig significantly reduces gas consumption.

Due to the structural invariance of Endless Account, off-chain multisig is less scalable and less versatile.

For more details, please refer to the following resources:

Last updated