soroban-client-nodejs
v1.0.0
Published
A Soroban RPC client for nodejs
Downloads
143
Readme
soroban-client-nodejs
A Soroban RPC client for nodejs
Usage
import { RPC } from '../rpc.js'
const sorobanUrl = 'http://[...].onion/rpc'
const proxyUrl = 'http://127.0.0.1:9150'
const client = new RPC(sorobanUrl, proxyUrl)
// Write 10 messages into the directory
for (let i=0; i < 10; i++) {
const msg = {'data': `msg${i}`}
await client.directoryAdd('test', JSON.stringify(msg), 'long')
}
// Wait for a message received under the "test" key and delete it
// Wait for message for 2s max (10*200ms)
const entry = await client.waitAndRemove('test', 10)
// Read all messages received under the "test" key
const entries = await client.directoryList('test')
// Remove first message
await client.directoryRemove('test', JSON.stringify(entries[0]))