Skip to content
gunaseelan.dev
Go back

Setting Up a Sui Multisig Account: A Step-by-Step Guide

Published:
•4 min read
Setting Up a Sui Multisig Account: A Step-by-Step Guide

A step-by-step tutorial for creating a secure multi-signature account on the Sui blockchain

Introduction

Multisig accounts enhance blockchain security by requiring multiple signatures to authorize transactions, reducing single points of failure. In this guide, we’ll set up a 2-of-3 multisig account on Sui — three owners with weighted signatures, requiring combined weight of 3 to execute transactions.

Why Use Multisig Accounts?

Prerequisites

Step 1: Creating Owner Accounts

First, we need to create the accounts that will share control of our multisig account.

Open your terminal and run these commands:

sui client new-address ed25519 owner1 
sui client new-address secp256k1 owner2 
sui client new-address secp256k1 owner3

After running these, you’ll get output like this:

╭────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Created new keypair and saved it to keystore.                                                      │
├────────────────┬───────────────────────────────────────────────────────────────────────────────────┤
│ alias          │ owner1                                                                             │
│ address        │ 0x16a4a0747294891f39f8aea795ed9252d25eb7a19ccbdc45059184d08cb298e0                │
│ keyScheme      │ ed25519                                                                           │
│ recoveryPhrase │ mistake empty village thrive predict maze twist define brand repeat craft swallow │
╰────────────────┴───────────────────────────────────────────────────────────────────────────────────╯
╭─────────────────────────────────────────────────────────────────────────────────────────────╮
│ Created new keypair and saved it to keystore.                                               │
├────────────────┬────────────────────────────────────────────────────────────────────────────┤
│ alias          │ owner2                                                                      │
│ address        │ 0xf950e5560f31e0815dad9c4b96e0af94d1528b96aa4324f42887ea9ef03e1fa9         │
│ keyScheme      │ secp256k1                                                                  │
│ recoveryPhrase │ muscle morning tiger trust rail chair invest throw crisp critic photo deal │
╰────────────────┴────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────╮
│ Created new keypair and saved it to keystore.                                                 │
├────────────────┬──────────────────────────────────────────────────────────────────────────────┤
│ alias          │ owner3                                                                        │
│ address        │ 0x4779377e48802c2f2e21950b230d9f4ba1589a9effd4024377161e0463b2cc96           │
│ keyScheme      │ secp256k1                                                                    │
│ recoveryPhrase │ toilet lawn rural wonder taste sight table shrimp pistol capital caught dune │
╰────────────────┴──────────────────────────────────────────────────────────────────────────────╯

Save these addresses in environment variables for easy reference:

owner1_addr=0x16a4a0747294891f39f8aea795ed9252d25eb7a19ccbdc45059184d08cb298e0
owner2_addr=0xf950e5560f31e0815dad9c4b96e0af94d1528b96aa4324f42887ea9ef03e1fa9
owner3_addr=0x4779377e48802c2f2e21950b230d9f4ba1589a9effd4024377161e0463b2cc96

Step 2: Getting Public Keys

We need the public keys for each owner to create the multisig account:

sui keytool list

This shows all your keys with their public keys. Copy the publicBase64Key for each owner:

owner1_pubkey=<OWNER1-PUBLIC-KEY>
owner2_pubkey=<OWNER2-PUBLIC-KEY>
owner3_pubkey=<OWNER3-PUBLIC-KEY>

Step 3: Creating the Multisig Account

Now let’s create our multisig account with weighted signatures:

sui keytool multi-sig-address \
  --pks $owner1_pubkey $owner2_pubkey $owner3_pubkey \ 
  --weights 1 2 2 \ 
  --threshold 3

This creates a 2-of-3 setup where:

The command will output your new multisig address:

multisig_addr=<YOUR-MULTISIG-ADDRESS>

Step 4: Funding the Multisig Account

The multisig account needs some SUI to execute transactions. Visit https://faucet.sui.io to fund your multisig account, then verify:

sui client gas $multisig_addr

Step 5: Creating a Transaction

Let’s create our first transaction using the multisig account. We’ll transfer some SUI to another address.

Define the recipient and amount:

RECIPIENT_ADDRESS=0xfe65fb1d1df439982c0e5191151ad3a6dec85d44870435a3380fc65cda6700bb
coin=<GAS-COIN-ID>  # Get this from the gas command above

Create an unsigned transaction:

sui client transfer \
  --to $RECIPIENT_ADDRESS \
  --object-id $coin \
  --serialize-unsigned-transaction

Save the transaction bytes:

txbytes=<YOUR-TX-BYTES>

Step 6: Collecting Signatures

Now we need to collect signatures. Since we need combined weight of 3, let’s get signatures from Owner 1 and Owner 2:

sui keytool sign --address $owner1_addr --data $txbytes
sui keytool sign --address $owner2_addr --data $txbytes

Save both signatures:

sig_1=<OWNER1-SIGNATURE>
sig_2=<OWNER2-SIGNATURE>

Step 7: Combining Signatures

Combine the individual signatures into a multisig signature:

sui keytool multi-sig-combine-partial-sig \
  --pks $owner1_pubkey $owner2_pubkey $owner3_pubkey 
  --weights 1 2 2 
  --threshold 3 
  --sigs $sig_1 $sig_2

Save the combined signature:

multisig_hash=<COMBINED-MULTISIG-SIGNATURE>

Step 8: Executing the Transaction

Finally, execute the multisig transaction:

sui client execute-signed-tx \
  --tx-bytes $txbytes \
  --signatures $multisig_hash

Advanced Features

Different Signature Combinations

With our weighted setup, these combinations work:

Future Developments

The Sui multisig implementation continues to evolve. Potential improvements include:

Conclusion

Multisig accounts provide essential security for serious blockchain operations. Sui’s implementation with weighted signatures offers flexibility while maintaining security.

Whether you’re protecting personal assets, managing team funds, or securing a DAO treasury, multisig accounts add crucial protection. The setup complexity is a small trade-off for the significant security benefits.


Originally published on Medium.