You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nitowa 4a73cda7aa improve readme 2 years ago
src fix exporting and doc generation missing types 2 years ago
test fix exporting and doc generation missing types 2 years ago
.drone.yml npm access token 2 years ago
.gitignore fix doc generation 2 years ago
LICENSE.md rebase to npm-packages, add README and LICENSE 2 years ago
README.md improve readme 2 years ago
package-lock.json fix exporting and doc generation missing types 2 years ago
package.json improve readme 2 years ago
tsconfig.json update testnet node address because it moved 2 years ago

README.md

Overview

Build Status Current Version Weekly Downloads License Type

xrpio is a library that allows you to write and read arbitrary data in the ripple blockchain.

How to install

npm i xrpio

Quickstart

import {RippleAPI} from 'ripple-lib'
import {treeRead, treeWrite} from 'xrpio'

const api = new RippleAPI({ server: "..." }) 
await api.connect()

const dataRootHash = await treeWrite(
    api, 
    "Arbitrary string data 123", 
    { 
        address: "Sender address", 
        secret: "Sender private key"
    }, 
    "Receiver address"
)

const data = await treeRead(api, [dataRootHash])
console.log(data) //"Arbitrary string data 123"

A simple run-ready example for the testnet

import { treeRead, treeWrite, Wallet } from 'xrpio'
import { RippleAPI } from 'ripple-lib'
import fetch from 'node-fetch'

export const makeTestnetWallet = () : Promise<Wallet> => fetch('https://faucet.altnet.rippletest.net/accounts', {
    method: 'POST',
    headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json'
    },
}).then((raw:any) => {
    return raw.json().then(content => content.account)
});

(async()=>{
    const api = new RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'})
    await api.connect()
    const fromWallet = await makeTestnetWallet()
    const toWallet = await makeTestnetWallet()
    await new Promise((res, rej) => setTimeout(res, 10000)) //it takes a moment for the wallets to become active

    const rootHash = await treeWrite(api, "test123", fromWallet, toWallet.address)
    const data = await treeRead(api, [rootHash])
    console.log(data)    
})()

Full documentation