Try   HackMD

Updated on 8/1/2023

Multisign Wallets

Setup Personal Wallet

Setup script will place liked binary on your home directory.

  • Create a keypair for creating multisign wallet.
liked keys add ##YOUR_KEY_NAME##
  • Replace ##YOUR_KEY_NAME## with name of your actual key.
  • By default, liked will use your operating system's keyring/credentials store to store key pairs. Depending on operating system, you may be required to enter a password to protect your keystore. You will need to repeat that password. If you want to force the key to be stored in a flat file for easier backup, you may append --keyring-backend=file .
  • The output is your key's info, including address, public key and mnemonic phrase. For example:
    - name: testing
      type: local
      address: cosmos1r4w76jr8y8tykypyd2aamsjvcv6hp40natnly9
      pubkey: cosmospub1addwnpepq2m52k8j4an483st50a2hz74us394j602n6easn6vnps3z9qrckly6vc7we
      mnemonic: ""
      threshold: 0
      pubkeys: []
    
    **Important** write this mnemonic phrase in a safe place.
    It is the only way to recover your account if you ever forget your password.
    
    fortune supreme exile candy surprise turtle exotic dizzy lunar cart patch twenty arch good oval conduct gallery phrase fence royal source hurt echo useful

  • The cosmos1r4w76jr8y8tykypyd2aamsjvcv6hp40natnly9 part is the address
  • The cosmospub1addwnpepq2m52k8j4an483st50a2hz74us394j602n6easn6vnps3z9qrckly6vc7we part is the public key
  • The fortune supreme ... part is the mnemonic phrase.
  • Backup the address, public key and mnemonic phrase. Store them in some secure way, e.g. in password manager.

Construct the multisig key and address

  1. Users share their public key to each other.

  2. Each user run the following command for each public key:

    ​​​​liked keys add ##KEY_N_NAME## --pubkey ##PUBLIC_KEY_N##
    

    where:

    • ##KEY_N_NAME## is a name to refer to this specific key
    • ##PUBLIC_KEY_N## is the public key itself

    Repeat this command for each public key, for example:

    ​​​​liked keys add tom --pubkey cosmospub1addwnpepq2m52k8j4an483st50a2hz74us394j602n6easn6vnps3z9qrckly6vc7we
    ​​​​liked keys add mary --pubkey cosmospub1addwnpepqgaqm5mhm66yfh0svdh36423q438txc7t80hwvrg93ee5maqg3zpz3m49aw
    ​​​​liked keys add peter --pubkey cosmospub1addwnpepq0aldgc07gh855jlm2w90nkyny45f2hg8ft0g4c668002u60e9wyv3cpzt2
    ​​​​...
    
  3. After having all public key in the keystore, each user construct the multisig key by running:

    ​​​​liked keys add --multisig ##KEY_1_NAME##,##KEY_2_NAME##,...,##KEY_N_NAME## --multisig-threshold ##M## ##MULTISIG_KEY_NAME##
    

    where:

    • ##KEY_1_NAME##,##KEY_2_NAME##,...,##KEY_N_NAME## is the names of the keys (including your own one) joined together by comma (,)
    • ##M## is the multisig threshold (i.e. you need at least this number of users signed for sending a transaction using this multisig address)
    • ##MULTISIG_KEY_NAME## is the name of the multisig key in the keystore
  4. Confirm the generated multisig address from the output with each other users.

Create Raw Transaction JSON

Delegatuon / Redelegation

@KenOokamiHoro is working on progress for make this process programmatical Automatically.

Withdraw Rewards

It should be done when here is delegation changes. (Undelegate/Redelegate)

One of multisign wallet user run this command:

liked tx distribution withdraw-all-rewards \
    --generate-only \
    # Replace ##MULTISIG_WALLET_ADDRESS## with the generated multisig wallet address.
    --from ##MULTISIG_WALLET_ADDRESS## \
    # Adjust --chain-id ,--gas-prices and --gas if needed in the future.
    --chain-id likecoin-mainnet-2 \
    --gas-prices "2000nanolike" \
    --gas 2000000 \
    # By default, liked will connect to LikeCoin node which installed locally. 
    # In this case, it is unlikely that there will be a node locally, and you can use --node parameter to connect to the RPC API of a remote node.
    # Some vaildators may provide RPC API either, you may change it if necessary.
    --node https://mainnet-node.like.co:443/rpc/

For example:

~/liked tx distribution withdraw-all-rewards --generate-only --from like1w8v28mq4979x3w5jseqfggg3e8xck0l8m6errh --chain-id likecoin-mainnet-2 --gas-prices "2000nanolike" --gas 10000000 --node https://likecoin-rpc.yoitsu.xyz:443/

You may combine other commands and pipelines if available, for example, using jq for formatting text and use tee for outputting it to a file.

~/liked tx distribution withdraw-all-rewards --generate-only --from like1w8v28mq4979x3w5jseqfggg3e8xck0l8m6errh --chain-id likecoin-mainnet-2 --gas-prices "2000nanolike" --gas 10000000 --node https://likecoin-rpc.yoitsu.xyz:443/ | jq '.' | tee tx_unsigned.json 

Then send output JSON file to others.

Signing and Collecting Signatures

Each member runs the following command to perform the signature operation:

# Replace ##RAW_TRANSACTION_JSON## to filename of your downloaded raw transaction JSON.
liked tx sign ##RAW_TRANSACTION_JSON## \
# Replace ##MULTISIG_KEY_NAME## and ##YOUR_KEY_NAME## to the name of multisig wallet and your private key.
# You may use "liked keys list" for getting them if needed.
    --multisig=##MULTISIG_KEY_NAME## \
    --from=##YOUR_KEY_NAME## \
# Adjust --chain-id, --node and --keyring-backend as previous if needed.
    --chain-id likecoin-mainnet-2 \
    --node https://mainnet-node.like.co:443/rpc/
    --keyring-backend=file

For example:

~/liked tx sign tx_20230725_withdraw_rewards.json --multisig=cdc2023 --from=FooHoro --chain-id likecoin-mainnet-2 --node https://likecoin-rpc.yoitsu.xyz:443/ --keyring-backend=file

Depending on the environment, you may be asked to enter a passphrase for your private key. The signature may like this:

# Here using a formatter to make the results more readable, your results should be only one line.
# Oddly enough, pipes don't seem to work here.
{
  "signatures": [
    {
      "public_key": {
        "@type": "/cosmos.crypto.secp256k1.PubKey",
        "key": "AqYhuXvCcZU9UqeUrQtHuejElEUOfEHhRWfH6kqqfZQz"
      },
      "data": {
        "single": {
          "mode": "SIGN_MODE_LEGACY_AMINO_JSON",
          "signature": "gPca7mknpEYPG+swsoQ1jLA0A1f2RTGfJxF94/QE8fI5G7dYUMsVCc78y07HOzMP4syDj+q+rLg/aUDUgJQ9ew=="
        }
      },
      "sequence": "2"
    }
  ]
}

Then copy your signature to a text file and send to others.

Combining Signstures

One committe member runs the following command to perform combining signatures:

# Replace ##RAW_TRANSACTION_JSON## to filename of your downloaded raw transaction JSON, and ##MULTISIG_KEY_NAME## and ##YOUR_KEY_NAME## to the name of multisig wallet as signing process.
liked tx multisign ##RAW_TRANSACTION_JSON## \
    ##MULTISIG_KEY_NAME## \
# Replace ###SIGNATURES### for filename of your downloaded signatures.
    ###SIGNATURES###
    --chain-id likecoin-mainnet-2 \
    --node https://mainnet-node.like.co:443/rpc/
    --keyring-backend=file

For example:

~/liked tx multisign tx.json cdc2023 signature_1.json signature_2.json signature_3.json signature_4.json --chain-id likecoin-mainnet-2 --node https://mainnet-node.like.co:443/rpc/ --keyring-backend=file

Depending on the environment, you may be asked to enter a passphrase for your private key, and copy output to a new text file.

Broadcasting Transaction

IMPORTANT: The process of broadcasting a transaction can be performed ONLY ONCE, regardless of whether the transaction is successful or not, and attempting to combine signatures or broadcast transactions again will result in an "Unable to verify signatures" error message, so if the transaction fails at a later time, please adjust raw transaction and redo the signing process.

Committee member which have signed transaction JSON runs the following command:

# Replace ##SIGNED_TX_FILENAME## to filename of your signed transaction JSON.
liked tx broadcast ##SIGNED_TX_FILENAME## \
    --chain-id likecoin-mainnet-2 \
    --node https://mainnet-node.like.co:443/rpc/
# You may append --yes to skip confirmation.    
    --yes

For example:

 ~/liked tx broadcast signed-tx.json --chain-id likecoin-mainnet-2 --node https://mainnet-node.like.co:443/rpc/

The output may like this:

code: 0
codespace: ""
data: ""
events: []
gas_used: "0"
gas_wanted: "0"
height: "0"
info: ""
logs: []
raw_log: '[]'
timestamp: ""
tx: null
txhash: 4628B3721E0DC7B21D342DA525BD0EFFCC455E365892E4B6B9F0F8C60968DB50

You may copy value of txhash and query on blockchain browser later, for example: