improve readme
This commit is contained in:
@@ -14,6 +14,7 @@ npm i xrpio
|
||||
|
||||
# Quickstart
|
||||
```typescript
|
||||
import {RippleAPI} from 'ripple-lib'
|
||||
import {treeRead, treeWrite} from 'xrpio'
|
||||
|
||||
const api = new RippleAPI({ server: "..." })
|
||||
@@ -31,7 +32,35 @@ const dataRootHash = await treeWrite(
|
||||
|
||||
const data = await treeRead(api, [dataRootHash])
|
||||
console.log(data) //"Arbitrary string data 123"
|
||||
```
|
||||
|
||||
# A simple run-ready example for the testnet
|
||||
```typescript
|
||||
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](https://gitea.nitowa.xyz/docs/xrpio)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xrpio",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.3",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitea.nitowa.xyz/npm-packages/xrpio.git"
|
||||
|
||||
Reference in New Issue
Block a user