LogoLogo
  • Welcome
  • XRPL Basics
    • Getting Started
    • Payments
    • Reading and subscribing to Transactions
    • Writing and reading memos
    • Non Fungible Tokens
    • PathFinding
    • Escrow
    • Price Oracles
    • Tickets
    • Multi-Signature
  • Token Issuance and Liquidity
    • Creating Accounts
    • Issuing Tokens
    • Creating an AMM Pool
  • Cyphered Chat on XRPL
    • Set up
    • Set up Keys
    • Cypher the message
    • Set up the memo & send the tx
    • Get the message and decypher it
  • EVM Sidechain
    • Connecting Metamask
    • Bridging Assets
    • Remix
    • Banking App
    • Banking Contract Key Concepts
  • Tools
    • Xaman Setup
    • Metamask Setup
Powered by GitBook
On this page
  • Introduction
  • MultiSign Explained
  • 1. Configuration and Setup
  • 2. Establishing a Quorum
  • 3. Transaction Authorization
  • 4. Enhanced Security Features
  • 5. Customizable Flexibility
  • Why MultiSignature Stands Out
  • 1. Distributed Control and Governance
  • 2. Enhanced Security Against Threats
  • 3. Fostering Trust in Shared Transactions
  • 4. Risk Mitigation for Organizations
  • 5. Customizable for Your Needs
  • What are we going to do
  • Setup
  • Creating a Transaction
  • Key Points to Remember
Export as PDF
  1. XRPL Basics

Multi-Signature

In this session, we will work with multiple signatures

Introduction

MultiSignature (or MultiSig) on the XRPL allows multiple users to collectively authorize transactions from a shared account. This ensures enhanced security and reduces risks associated with a single point of control. Think of it like a group-controlled vault where multiple stakeholders must approve access.


MultiSign Explained

1. Configuration and Setup

MultiSignature starts with a shared account on the XRPL. This account is configured with specific rules, defining how many and which signers are required for transaction approval. Each signer is assigned a "weight," reflecting their influence in the decision-making process.

2. Establishing a Quorum

The quorum is the minimum number of signers required to authorize a transaction. For example, a quorum of three means at least three pre-approved parties must sign off for the transaction to proceed.

3. Transaction Authorization

When a transaction is initiated, it must receive the necessary number of approvals as specified in the MultiSignature configuration. For instance, if the quorum requires two out of three signers, the transaction will execute only after two parties provide their signatures.

4. Enhanced Security Features

MultiSignature ensures that even if one signer's private key is compromised, unauthorized transactions cannot occur without meeting the quorum. This reduces risks associated with fraud or hacking.

5. Customizable Flexibility

MultiSignature is highly adaptable, allowing configurations to be updated over time. For example, fewer signers can be required for everyday transactions, but unanimous approval might be enforced for high-value transfers.


Why MultiSignature Stands Out

1. Distributed Control and Governance

MultiSignature decentralizes decision-making power by requiring consensus from multiple signers. This ensures no single individual has complete control, making it ideal for businesses, joint ventures, and collaborative setups.

2. Enhanced Security Against Threats

By requiring multiple approvals, MultiSignature significantly reduces the risk of unauthorized transactions, even if one key is compromised. This layered security is a robust defense against hacking and fraud.

3. Fostering Trust in Shared Transactions

MultiSignature enhances trust in shared financial operations by ensuring transparency and consensus among all parties involved.

4. Risk Mitigation for Organizations

MultiSignature mitigates risks such as insider threats and key compromises by spreading responsibility across multiple signers.

5. Customizable for Your Needs

Configurations can be tailored to operational requirements, such as setting different approval thresholds for routine versus high-value transactions.


What are we going to do

  • Wallet Initialization Create wallets for the main account and the signers using their seeds.

  • Setting Up the Signer List Configure the signer list with their respective weights and set the quorum.

  • Submitting the SignerListSet Transaction Send the signer list configuration to the XRPL.

  • Creating the Payment Transaction Define the payment transaction that will be multi-signed.

  • Autofilling Transaction Details Use autofill to complete transaction fields like Sequence and Fee.

  • Signing the Transaction by Each Signer Each signer independently signs the transaction.

  • Combining the Signatures Use multisign to combine the individual signatures into one transaction.

  • Submitting the MultiSigned Transaction Submit the combined transaction to the XRPL.

Setup

Accounts

For this example you need a total of four accounts:

  1. One main account

  2. Three signers

The signers do not require funds but must enable the master key.

  • SignerQuorum: The minimum weight sum required for valid transactions.

  • SignerEntries: A list with at least one member and no more than 32 members.


Create Wallets

import { Client, Wallet, multisign } from "xrpl";

const client = new Client("wss://s.altnet.rippletest.net:51233");
await client.connect();

const mainSeed = "s...";
const signerSeed_1 = "s...";
const signerSeed_2 = "s...";
const signerSeed_3 = "s...";

const mainWallet = Wallet.fromSeed(mainSeed);
const signer_1 = Wallet.fromSeed(signerSeed_1);
const signer_2 = Wallet.fromSeed(signerSeed_2);
const signer_3 = Wallet.fromSeed(signerSeed_3);

// Fund the main wallet only (testnet)
await client.fundWallet(mainWallet);

Generate Wallets instead

Alternatively you can create Wallets dynamically:

const mainWallet = Wallet.generate();

Create and Set the Signer List

const SignerListSetTransaction = {
   TransactionType: "SignerListSet",
   Account: mainWallet.classicAddress,
   SignerQuorum: 2,
   SignerEntries: [
      {
         SignerEntry: {
            Account: signer_1.classicAddress,
            SignerWeight: 2
         }
      },
      {
         SignerEntry: {
            Account: signer_2.classicAddress,
            SignerWeight: 1
         }
      },
      {
         SignerEntry: {
            Account: signer_3.classicAddress,
            SignerWeight: 1
         }
      }
   ]
};

try {
   const result = await client.submitAndWait(SignerListSetTransaction, { autofill: true, failHard: true, wallet: mainWallet });
   console.log('SignerListSet Transaction Result:', result);
} catch (error) {
   console.error('Failed to submit transaction:', error);
}

Creating a Transaction

Create Transaction

In this example, we prepare a simple payment transaction to be later signed using MultiSignature. The transaction sends 1 XRP (in drops) from the main account to a specified destination address.

const transaction = {
   TransactionType: "Payment",
   Account: mainWallet.classicAddress,
   Destination: "rrrrrrrrrrrrrrrrrNAMEtxvNvQ",
   Amount: '1000000' // 1 XRP expressed in drops
};

Prepare the transaction

const autofilledTransaction = await client.autofill(transaction, 3);
console.log('Transaction to sign:', autofilledTransaction);

Signing the Transaction

const signedWallet_1 = signer_1.sign(autofilledTransaction, true);
const signedWallet_2 = signer_2.sign(autofilledTransaction, true);
const signedWallet_3 = signer_3.sign(autofilledTransaction, true);

console.log('Signed by Signer 1:', signedWallet_1);
// Sample Output:
// {
//   tx_blob: '1200002200000000...F1',
//   hash: '5C4AC6A8FF7E3B...'
// }

Combine the signatures

const combinedTransaction = multisign([signedWallet_1.tx_blob, signedWallet_2.tx_blob, signedWallet_3.tx_blob]);
console.log(combinedTransaction);
// '12000022000......97A6AEE1F1'

Submit

try {
   const result = await client.submitAndWait(combinedTransaction);
   console.log('Transaction Submit Result', result);
   // Sample Output:
   // {
   //   result: {
   //     accepted: true,
   //     engine_result: 'tesSUCCESS',
   //     tx_json: { ... },
   //     validated_ledger_index: ...
   //   }
   // }

} catch (error) {
   console.error('Failed to submit transaction:', error);
}

Key Points to Remember

  1. Signer Weights and Quorum

    • The sum of the signer weights must meet or exceed the SignerQuorum for a transaction to be valid.

    • In the example, Signer 1 has a weight of 2, while Signers 2 and 3 have a weight of 1 each.

  2. Fee Calculation

    • Multi-signed transactions require higher fees due to their increased complexity.

    • Ensure the fee is sufficient to cover the multi-signature. In this example we used autofill(transaction, 3) specifying 3 signers for the Fee calculation.

  3. Transaction Sequence or Tickets

    • In this example, we use the Sequence number provided by autofill.

  4. Asynchronous Signing

    • Each signer can sign the transaction independently and at different times.

  5. Security Considerations

    • MultiSignature enhances security by requiring multiple keys to authorize a transaction.

    • Even if one key is compromised, the attacker cannot perform unauthorized transactions without additional signatures, if the signer list is correctly set.


With MultiSignature, you can ensure robust security and reliable transaction governance on the XRPL.

PreviousTicketsNextToken Issuance and Liquidity

Last updated 2 months ago

With the accounts we just created we want to configure our signerlist and submit this to the ledger, we do this by creating a .

For creating transactions in a multi-sign environment, you have two options: either use or a . Tickets are used to reserve sequence numbers. Since MultiSign transactions are asynchronous, the sequence number the transactions have been based on might be outdated. In this example, we do not use Tickets.

The fee and Sequence needs to be set in advance. The calculation for it goes as follows: (Base Fee + (Incremental Fee × Number of Signers)). We can use for this, 3 is the number of signers.

Each signer will the same Transaction

all signatures for one final Transaction

the multi-signed transaction

Multi-signing is asynchronous, so using Tickets can help manage sequence numbers. More information here:

SignerListSet transaction
Sequence
Ticket
.autofill()
sign
Combine
Submit
https://xrpl.org/docs/concepts/accounts/tickets