Demos Network Specifications
  • Introduction
    • What is Demos Network
    • Demos Network Architecture
  • FAQ
  • Cookbook
    • Project setup
      • Run the project (MacOS)
      • Run the project (Windows)
        • WSL 2 Setup on Windows (10 and 11 only)
        • Issue Troubleshooting
      • Run the project (Ubuntu)
  • SDK
    • Getting Started
    • WebSDK
      • Authentication
        • FIDO2 Passkeys
          • Under the Hood: FIDO2 Passkeys
      • NodeCalls
      • Transactions
        • Creating a transaction
        • Signing a transaction
        • Broadcasting a transaction
      • L2PS SDK
        • The l2ps module
        • Interacting with the L2PS
        • L2PS Messaging System
      • Instant Messaging
        • What is the Instant Messaging Protocol?
        • Architecture Overview
        • Encryption
        • Quickstart
        • Message Types
        • API Reference
        • FAQ
    • Cross Chain
      • General layout of the XM SDKs
      • EVM
      • BTC
      • Solana
      • MultiversX (EGLD)
      • NEAR
      • IBC
      • TON
      • XRPL
      • The XMScript
      • Identities
    • Demoswork
    • Cookbook
      • Demoswork
        • Creating work steps
        • Conditional Operation
        • Base Operation
        • Signing and broadcasting
      • Transactions
        • Crosschain Transaction
        • Native Transactions
      • SWAP
        • Crosschain SWAP
    • Web2
      • Quick Start
      • DAHR API Reference
        • Types
      • Making Requests
      • Identities
        • Twitter
        • GitHub
    • API Reference
    • Bridges
      • Rubic Bridge Test
    • Post Quantum Cryptography
  • Backend
    • Internal Mechanisms
      • Network Time Synchronization
      • Cross Context Identities
    • Global Change Registry
      • GCR Structure
      • How is GCR Synced?
    • Consensus Mechanism
      • Unparalleled Scalability
      • Decentralization in PoR-BFT
      • Enhanced Security
      • Comparative Advantage
      • Addressing Potential Criticisms
      • Conclusion
    • Communications Stack
    • L2PS (Subnet) Framework
      • How are L2PS transactions handled?
    • Miscellaneous
      • Browsing the Postgres DB via psql
    • Bridges
      • Rubic Bridge
    • Developers Testbed
      • Setting up the environment
      • Setting up the repository
      • Installing dependencies
      • Node Configuration
      • Running the node
  • Frontend
    • Demos Providers Discovery Mechanism
Powered by GitBook
On this page
  • Core Concepts
  • Setting up your wallet
  • Creating the SDK Instance
  • Connecting your wallet
  • Getting balance
  • Token transfer
  • Multiple transfers
  • Signing Messages
  • Advanced Usage
  • API Reference
  • Resources
  1. SDK
  2. Cross Chain

XRPL

PreviousTONNextThe XMScript

Last updated 3 months ago

The XRP Ledger is a decentralized cryptographic ledger powered by a network of peer-to-peer servers. It is fast, energy efficient, and reliable, with low transaction costs. XRP is the native cryptocurrency of the XRP Ledger, used to facilitate transactions on the network.

Core Concepts

  1. Accounts:

  2. Transactions:

  3. Consensus:

  4. Fees:

Setting up your wallet

To interact with the XRP Ledger, you need a wallet. You can use various wallet solutions, such as:

For development purposes, you can generate a test wallet using the .

Creating the SDK Instance

Import the SDK and create a new instance:

import { XRPL } from "@kynesyslabs/demosdk/xm-websdk"

const rpc_url = "wss://s.altnet.rippletest.net:51233"
const with_reconnect = false

const instance = new XRPL(rpc_url)

await instance.connect(with_reconnect)

The with_reconnect parameter is optional and defaults to true. It is used to specify whether the SDK should attempt to reconnect to the XRPL if the web socket connection is lost.

The XRPL SDK uses a web socket connection. HTTP RPCs are not supported.

Connecting your wallet

To perform transactions, connect your wallet to the SDK:

await instance.connectWallet("sEd7rBGm5kxzauR...")

You can view the address of your connected wallet using the getAddress method:

const address = instance.getAddress()
console.log(`Address: ${address}`)

Getting balance

To get the balance of an account:

const balance = await instance.getBalance("rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe")
console.log(`Balance: ${balance} XRP`)

Token transfer

To create a transaction to transfer XRP, use the preparePay method:

const signedTx = await instance.preparePay(
    "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
    "10",
)

The signedTx object contains the signed transaction that can be used in a DEMOS transaction.

Multiple transfers

To prepare multiple transfers at once, use the preparePays method:

const transfers = [
    { address: "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe", amount: "10" },
    { address: "rUCzEr6jrEyMpjhs4wSdQdz4g8Y382NxfM", amount: "20" },
]
const signedTxs = await instance.preparePays(transfers)

Signing Messages

const message = "Hello, world!"

// Signing
const signature = await instance.signMessage(message)

// Verifying signature
const verified = await instance.verifyMessage(
    message,
    signature,
    instance.wallet.publicKey,
)
expect(verified).toBe(true)

Advanced Usage

For more advanced use cases, you can access the underlying API to have more control over the transactions and interactions with the blockchain.

Here is a list of the objects you can access:

Method
Description

instance.provider

instance.wallet

instance.signTransaction(s)

Sign one or multiple transactions

xrplGetLastSequence

Get the last sequence number for an address

API Reference

Resources

The DEMOS XRPL SDK is built on top of the , and provides a limited set of methods to interact with the XRP Ledger.

The instance from the xrpl library

The instance for the connected account

XRPL Accounts
Transaction Basics
XRPL Consensus
XRPL Fees
GemWallet
XRPL Faucet
XRPL JS Library
https://kynesyslabs.github.io/demosdk-api-ref/classes/xmwebsdk.XRPL.html
XRPL Website
XRPL Testnet Faucet
XRPL Docs
XRPL JS Library
XRPL Explorer (Testnet)
Client
Wallet