🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@okxweb3/coin-xrp

Package Overview
Dependencies
Maintainers
8
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@okxweb3/coin-xrp

An XRP SDK for building Web3 wallets and applications.

latest
Source
npmnpm
Version
2.4.0
Version published
Maintainers
8
Created
Source

@okxweb3/coin-xrp

XRP SDK is used to interact with the xrp blockchain, it contains various functions can be used to web3 wallet.

Installation

Npm

To obtain the latest version, simply require the project using npm :

npm install @okxweb3/coin-xrp

Usage

Generate Private Key

import { XrpWallet } from "@okxweb3/coin-xrp"

let wallet = new XrpWallet();
// get random key
let randomPrivateKey = await wallet.getRandomPrivateKey();

// get derived key
let params = {
    mnemonic: "stool trumpet fame umbrella bench provide battle toward story fruit lock view",
    chainPath: "m/44'/144'/0'/0/1"
}
let derivePrivateKey = await wallet.getDerivedPrivateKey(params);

Private Key Derivation

import { XrpWallet } from "@okxweb3/coin-xrp"

let wallet = new XrpWallet();
let mnemonic = "stool trumpet fame umbrella bench provide battle toward story fruit lock view"
let param = {
  mnemonic: mnemonic,
  hdPath: "m/44'/144'/0'/0/0"
};

let privateKey = await wallet.getDerivedPrivateKey(param)

Generate Address

import { XrpWallet } from "@okxweb3/coin-xrp"

let wallet = new XrpWallet();
let params = {
    privateKey: 'EDD2AF6288A903DED9860FC62E778600A985BDF804E40BD8266505553E3222C3DA'
}
let newAddress = await wallet.getNewAddress(params);

Verify Address

import { XrpWallet } from "@okxweb3/coin-xrp"

let wallet = new XrpWallet();
let params = {
    address: "rQKQsPeE3iTRyfUypLhuq74gZdcRdwWqDp"
};
let valid = await wallet.validAddress(params);

Sending a Transfer Transaction

Use the signTransaction function to get the signed hex to broadcast

Example

import { XrpWallet } from "@okxweb3/coin-xrp"

let wallet = new XrpWallet();
let signParams = {
    privateKey: seed1,
    data: {
        type: "transfer" ,
        base: {
            Account:"rnyyyTfmc4MLRXqn7fhJW51fxttPp4djHw",
            Flags: 0,
            Fee:"12",
            Sequence:5779448,
            LastLedgerSequence: 5784941
        },
        data: {
            TransactionType: 'Payment',
            Amount: '1.23',
            Destination: 'rJdzXHR7qcPTqpESwJt5TJDhqaRe8oVAgE',
        }
    }
}
let tx = await wallet.signTransaction(signParams)

trust set

Use the signTransaction function to get the signed hex to broadcast

Example

import { XrpWallet } from "@okxweb3/coin-xrp"

let wallet = new XrpWallet();
let signParams = {
    privateKey: seed1,
    data: {
        type: "TrustSet" ,
        base: {
            Account:"rnyyyTfmc4MLRXqn7fhJW51fxttPp4djHw",
            Flags: 0,
            Fee:"12",
            Sequence:5779449,
            LastLedgerSequence: 5785541
        },
        data: {
            Account: 'rnyyyTfmc4MLRXqn7fhJW51fxttPp4djHw',
            LimitAmount: {
                currency: "USD",
                issuer: "rJdzXHR7qcPTqpESwJt5TJDhqaRe8oVAgE",
                value:"123",
            }
        }
    }
}
let tx = await wallet.signTransaction(signParams)

send currency

Use the signTransaction function to get the signed hex to broadcast

Example

import { XrpWallet } from "@okxweb3/coin-xrp"

let wallet = new XrpWallet();
let signParams = {
    privateKey: seed2,
    data: {
        type: "transfer" ,
        base: {
            Account:address2,
            Flags: 0,
            Fee:"12",
            Sequence:5779442,
            LastLedgerSequence: 5786248
        },
        data: {
            Destination:address1,
            Amount: {
                currency: "USD",
                issuer: address2,
                value:"1.23",
            }
        }
    }
}
let tx = await wallet.signTransaction(signParams)

Sign Message

 const msg = {
            messageId: "123",
            url: "",
            title: "",
            favicon: "",
            message: "",
        }
const sig = await wallet.signMessage({
    privateKey: "003BA2B1DB9231EEEB6F85EEEF0B4F71B493DBDC315E6458480B378D73FAFA1398",
    data: msg,
})

License

MPL-2.0

Keywords

xrp

FAQs

Package last updated on 09 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts