Lets write a nodejs program to fetch application details from XUMM platform. We’ll also see how to retrieve all the IOU details using single line of code.
Page Contents
Video Tutorial: Send Ping Request To XUMM Platform and Get Application Details
[youtube https://www.youtube.com/watch?v=3jvkJUJMUpQ]
Source Code: Send Ping Request To XUMM Platform and Get Application Details
const {XummSdk} = require('xumm-sdk') const Sdk = new XummSdk('Your-API-Id', 'Your-API-Secret') const main = async () => { const appInfo = await Sdk.ping() } main()
Output
$ node index.js { quota: {}, application: { uuidv4: '401015ee-7edc-4469-bdfd-3af11f229885', name: 'My Super Duper App!', webhookurl: 'https://technotip.com', disabled: 0 }, call: { uuidv4: 'a47219a5-8802-44d2-84bf-0c692ff05e48' } }
Most part of above code in taken from our previous video tutorial, so please visit Prepare Your Project & Start Coding: XUMM SDK before going further.
Explanation of Above Source Code
We are writing a asynchronous function and the child process waits for the result from Sdk.ping() method. Once the result is retrieved, the result is printed on to the console window.
Since we are writing asynchronous method, we need to use await keyword to wait for the result or the promise to be resolved.
If we do not write the await keyword, you’ll get the following result:
const {XummSdk} = require('xumm-sdk') const Sdk = new XummSdk('Your-API-Id', 'Your-API-Secret') const main = async () => { const appInfo = Sdk.ping() } main()
Output
$ node index.js Promise {}
That’s because the child process didn’t wait for the result to be returned or the promise to be resolved.
Display XUMM Application Name
const {XummSdk} = require('xumm-sdk') const Sdk = new XummSdk('Your-API-Id', 'Your-API-Secret') const main = async () => { const appInfo = await Sdk.ping() console.log(appInfo.application.name) } main()
Output
$ node index.js My Super Duper App!
Here we fetch the name of the XUMM application by traversing the json output, using DOT(.) notation. name key is present inside key application.
Display XUMM Curated Assets: IOU Details
const {XummSdk} = require('xumm-sdk') const Sdk = new XummSdk('Your-API-Id', 'Your-API-Secret') const main = async () => { const IOU = await Sdk.getCuratedAssets() console.log(IOU) } main()
Output
$ node index.js { issuers: [ 'Bitstamp', 'GateHub', 'Towo Labs', 'Sologenic', 'Wietse' ], currencies: [ 'USD', 'BTC', 'EUR', 'ETH', 'BCH', 'ETC', 'XAU', 'DSH', 'REP', 'XTK', '534F4C4F00000000000000000000000000000000', 'WIE' ], details: { Bitstamp: { id: 185, name: 'Bitstamp', domain: 'bitstamp.net', avatar: 'https://xumm.app/assets/icons/currencies/ex-bitstamp.png', shortlist: 1, currencies: { USD: { id: 178, issuer_id: 185, issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', currency: 'USD', name: 'US Dollar', avatar: 'https://xumm.app/assets/icons/currencies/fiat-dollar.png', shortlist: 1 }, BTC: { id: 492, issuer_id: 185, issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', currency: 'BTC', name: 'Bitcoin', avatar: 'https://xumm.app/assets/icons/currencies/crypto-btc.png', shortlist: 1 } } }, GateHub: { id: 182, name: 'GateHub', domain: 'gatehub.net', avatar: 'https://xumm.app/assets/icons/currencies/ex-gatehub.png', shortlist: 1, currencies: { EUR: { id: 169, issuer_id: 182, issuer: 'rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq', currency: 'EUR', name: 'Euro', avatar: 'https://xumm.app/assets/icons/currencies/fiat-euro.png', shortlist: 1 }, USD: { id: 170, issuer_id: 182, issuer: 'rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq', currency: 'USD', name: 'US Dollar', avatar: 'https://xumm.app/assets/icons/currencies/fiat-dollar.png', shortlist: 1 }, BTC: { id: 172, issuer_id: 182, issuer: 'rchGBxcD1A1C2tdxF6papQYZ8kjRKMYcL', currency: 'BTC', name: 'Bitcoin', avatar: 'https://xumm.app/assets/icons/currencies/crypto-btc.png', shortlist: 1 }, ETH: { id: 174, issuer_id: 182, issuer: 'rcA8X3TVMST1n3CJeAdGk1RdRCHii7N2h', currency: 'ETH', name: 'Ethereum', avatar: 'https://xumm.app/assets/icons/currencies/crypto-eth.png', shortlist: 1 }, BCH: { id: 173, issuer_id: 182, issuer: 'rcyS4CeCZVYvTiKcxj6Sx32ibKwcDHLds', currency: 'BCH', name: 'Bitcoin Cash', avatar: 'https://xumm.app/assets/icons/currencies/crypto-bch.png', shortlist: 1 }, ETC: { id: 175, issuer_id: 182, issuer: 'rDAN8tzydyNfnNf2bfUQY6iR96UbpvNsze', currency: 'ETC', name: 'Ethereum Classic', avatar: 'https://xumm.app/assets/icons/currencies/crypto-etc.png', shortlist: 1 }, XAU: { id: 171, issuer_id: 182, issuer: 'rcoef87SYMJ58NAFx7fNM5frVknmvHsvJ', currency: 'XAU', name: 'Gold Gram', avatar: 'https://xumm.app/assets/icons/currencies/crypto-gold.png', shortlist: 1 }, DSH: { id: 177, issuer_id: 182, issuer: 'rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX', currency: 'DSH', name: 'Dash', avatar: 'https://xumm.app/assets/icons/currencies/crypto-dash.png', shortlist: 1 }, REP: { id: 176, issuer_id: 182, issuer: 'rckzVpTnKpP4TJ1puQe827bV3X4oYtdTP', currency: 'REP', name: 'REP', avatar: 'https://xumm.app/assets/icons/currencies/crypto-rep.png', shortlist: 1 } } }, 'Towo Labs': { id: 2601, name: 'Towo Labs', domain: 'xrptoolkit.com', avatar: 'https://xumm.app/assets/icons/currencies/xtk-symbol.png?2', shortlist: 1, currencies:{ XTK: { id: 9622, issuer_id: 2601, issuer: 'rXTKdHWuppSjkbiKoEv53bfxHAn1MxmTb', currency: 'XTK', name: 'XTK', avatar: 'https://xumm.app/assets/icons/currencies/xtk-symbol.png?2', shortlist: 1 } } }, Sologenic: { id: 4380, name: 'Sologenic', domain: 'sologenic.com', avatar: 'https://xumm.app/assets/icons/currencies/icon-sologenic.png', shortlist: 0, currencies:{ '534F4C4F00000000000000000000000000000000': { id: 861, issuer_id: 4380, issuer: 'rsoLo2S1kiGeCcn6hCUXVrCpGMWLrRrLZz', currency: '534F4C4F00000000000000000000000000000000', name: 'SOLO', avatar: 'https://xumm.app/assets/icons/currencies/icon-sologenic.png', shortlist: 0 } } }, Wietse: { id: 17553, name: 'Wietse', domain: 'wietse.com', avatar: 'https://xumm.app/assets/icons/currencies/wietse.jpg', shortlist: 0, currencies:{ WIE: { id: 17552, issuer_id: 17553, issuer: 'rwietsevLFg8XSmG3bEZzFein1g8RBqWDZ', currency: 'WIE', name: 'Wietse', avatar: 'https://xumm.app/assets/icons/currencies/transparent.png', shortlist: 0 } } } } }
IOU means “I owe you”. An “issuer” is the one who owe you, if you get funds as IOU transaction on XRP Ledger.
The acronym IOU stands for “I owe you” and refers to an informal document that acknowledges a debt one party owes to another.
When you run above code you can, programmatically, get to see all the supported IOU’s on XUMM platform. You can even get the issuer details, currency symbol and the name of the currency – just by running a single line of code.
IOU Details From Above Output
Bitstamp supports following currencies:
1. USD(US Dollar)
2. BTC(Bitcoin).
GateHub supports following currencies:
1. EUR(Euro)
2. USD(US Dollar)
3. BTC(Bitcoin)
4. ETH(Ethereum)
5. BCH(Bitcoin Cash)
6. ETC(Ethereum Classic)
7. XAU(Gold Gram)
8. DSH(Dash)
9. REP(REP)
Towo Labs supports following currency:
1. XTK(XTK)
Sologenic supports following currency:
1. SOLO(SOLO)
Wietse supports following currency:
1. WIE(Wietse)
Here ‘Bitstamp’, ‘GateHub’, ‘Towo Labs’, ‘Sologenic’, ‘Wietse’ are the issuers of the respective currencies. So you can transact above currencies on XRP Ledger via XUMM application.
As you can see from above examples, we’re successfully able to connect and communicate with XUMM platform. So in our next video tutorial lets send a simple PAYLOAD. More on that in next video tutorial, stay subscribed to our blog and YouTube channel.
For full “XUMM SDK/API” free video tutorial list visit: Working With XUMM SDK/API: XRPL