nitowa 0a970e5b9c remove test step from done | 2 år sedan | |
---|---|---|
src | 2 år sedan | |
test | 2 år sedan | |
.drone.yml | 2 år sedan | |
.gitignore | 2 år sedan | |
.npmignore | 2 år sedan | |
LICENSE.md | 2 år sedan | |
README.md | 2 år sedan | |
package-lock.json | 2 år sedan | |
package.json | 2 år sedan | |
tsconfig.json | 3 år sedan |
xrpio is a library that allows you to write and read arbitrary data in the ripple blockchain.
npm i xrpio
This library is in an early stage of development and breaking changes may occur spontaneously and without regard of semantic versioning until the v1.0.0 release.
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"
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)
})()