@montech-io/mox-ripple
v1.0.8
Published
This open-source package is built on top of XRP (Ripple) and provides various functions for interacting with the XRP network. It is designed to simplify the integration of XRP functionality into your projects.
Downloads
1
Readme
XRP Open-Source Package
This open-source package is built on top of XRP (Ripple) and provides various functions for interacting with the XRP network. It is designed to simplify the integration of XRP functionality into your projects.
Installation
To use this package, you need to have Node.js and npm (Node Package Manager) installed on your machine. You can install the package by running the following command:
npm install @montech-io/mox-ripple
Usage
To use this package, you need to import it into your project:
import RippleService from '@montech-io/mox-ripple';
Creating an Instance
To create an instance of the RippleService class, you need to provide the network, environment, and issuer address:
const rippleService = new RippleService(network, environment, issuerAddress);
network
(string): The XRP network to connect to. Example:mainnet: wss://s1.ripple.com
,testnet: wss://s.altnet.rippletest.net:51233
.environment
(string): The environment to use for generating an account. Example:"production"
,"development"
.issuerAddress
(string): The address of the issuer.
Generating an Account
To generate a new XRP account, you can use the generateAccount
function:
const wallet = await rippleService.generateAccount();
This function returns a new XRPL Wallet object.
For more information, refer to the XRPL Wallet Documentation.
Checking Trustline
To check if a trustline exists between two accounts, you can use the hasTrustline
function:
const hasTrustline = await rippleService.hasTrustline(account1, account2, currency);
account1
(string): The address of the first account.account2
(string): The address of the second account.currency
(string): The currency code of the trustline.
For more information, refer to the XRPL Trustline Documentation.
Transferring XRP
To transfer XRP from one account to another, you can use the transferXRP
function:
const tx = await rippleService.transferXRP(senderSecret, amount, recipient);
senderSecret
(string): The secret key of the sender's XRP account.amount
(string): The amount of XRP to transfer.recipient
(string): The address of the recipient's XRP account.
For more information, refer to the XRPL Payment Documentation.
Transfer Offers
To get the sell offers for a specific NFT token, you can use the transferOffers
function:
const sellOffers = await rippleService.transferOffers(tokenId);
tokenId
(string): The ID of the NFT token.
For more information, refer to the XRPL NFT Sell Offers Documentation.
More Functions
This package provides additional functions for various XRP operations, such as:
GetWalletNFTs(account: string)
: Retrieves the NFTs associated with a specific account.NFTokenTransferRequest(Secret: string, tokenOfferIndex: string)
: Performs an NFToken transfer request.resolveAccountFromSecret(secret: string)
: Resolves an account from a secret key.getAccountBalance(address: string)
: Retrieves the XRP balance