@setl/rlnsdk
v1.0.5
Published
An SDK for the RLN
Downloads
3
Readme
RLN SDK
SDK for triggering actions on the RLN
Prerequisites
This project requires NodeJS (developed on v18) and NPM. Node and NPM are really easy to install. To make sure you have them available on your machine, try running the following command.
$ npm -v && node -v
6.4.1
v8.16.0
Table of contents
Getting Started
Set up a new nodejs project in your development environment and install the library as follows
$ npm install @setl/rlnsdk
Usage
const RLN = require ('@setl/rlnsdk')
const rln = new RLN("rln-api.setlconnect.com", "USERNAME", "PASSWORD");
async function testrln(){
// Create an new transaction on the RLN
console.log('[create]')
res = await rln.create({
"id": "optional-id-for-whole-group-of-pac008s",
"from": "Test-participant-1",
"groups": [
{
"id": "optional-id-for-this-pac008-max35",
"transactions": [
{
"id": "optional-id-for-txn-max35",
"amount": 18.5,
"currency": "USD",
"creditor": {
"account": "Use a valid IBAN unless isAddress is true",
"agent": "Use a valid BIC",
"isAddress": false
},
"debtor": {
"account": "Use a valid IBAN unless isAddress is true",
"agent": "Use a valid BIC",
"isAddress": false
}
}
]
}
]
})
console.log(res)
// Query balances on the RLN
console.log('[Balance]')
res = await rln.balance({
walletId:1
})
console.log(res);
// Query transactions on the RLN
console.log('[Transactions]')
res = await rln.transactions({
incompleteOnly:true,
limit:10,
offset:0
})
console.log(res);
// Query the RLN for any transactions waiting for approval
console.log('[Approval List]')
res = await rln.approvalList()
console.log(res);
// Change the status of an transaction to APPROVE or REJECT
console.log('[Approval Status]')
res = await rln.approvalStatus({
"id": 2,
"status": "APPROVE"
})
console.log(res);
// Query the list of instruments that are being auto approved
console.log('[Autoapprove List]')
res = await rln.autoapproveList({})
console.log(res);
// Set up an instrument for autoapprove (set to 0 to turn it off)
console.log('[autoapprove]')
res = await rln.autoapprove({
username:"USERNAME",
assetCode:"USD",
maxAutoApprove:2000
})
console.log(res);
}
testrln()