Send Ping Request To XUMM Platform and Get Application Details

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.

Video Tutorial: Send Ping Request To XUMM Platform and Get Application Details


[youtube https://www.youtube.com/watch?v=3jvkJUJMUpQ]

YouTube Link: https://www.youtube.com/watch?v=3jvkJUJMUpQ [Watch the Video In Full Screen.]

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

Prepare Your Project & Start Coding: XUMM SDK

Lets install the software and packages needed to run a nodejs application and try to connect with the XUMM platform.

Software Required

1. Visual Studio Code Editor
2. Nodejs

Package To Be Installed

xumm-sdk (install via node package manager).

Video Tutorial: Prepare Your Project & Start Coding: XUMM SDK


[youtube https://www.youtube.com/watch?v=pgSckFopZ6Q]

YouTube Link: https://www.youtube.com/watch?v=pgSckFopZ6Q [Watch the Video In Full Screen.]

Lets test our installation

After installing Visual Studio Code Editor and Nodejs, lets create a new project. Create a file called index.js inside the project folder.
index.js

console.log("WELCOME TO XUMM SDK/API VIDEO TUTORIALS!")

Running Node Application
Command

 >node index.js

Output
WELCOME TO XUMM SDK/API VIDEO TUTORIALS!

If you get above output then your installation is working correctly. Lets move forward.

Installing xumm-sdk Package

Lets install xumm-sdk node package and try to connect with XUMM platform.

npm install xumm-sdk

It might take couple of seconds to couple of minutes depending on your internet connection speed. So you may have to wait patiently.

Error Message: Your npm doesn’t work with the version of Node

If you start getting error messages like: “npm WARN npm npm does not support Node.js” Just download lower version of Nodejs and try to run the program once again. In most of the cases the issue will be resolved.

Source Code: Importing xumm-sdk package into our project

const {XummSdk} = require('xumm-sdk')
const Sdk = new XummSdk('Your-API-Id', 'Your-API-Secret')

const main = async () => {
  console.log('XUMM SDK VIDEO TUTORIALS!')
}

main()

Run The Application
Command

 >node index.js

Output
XUMM SDK VIDEO TUTORIALS!

In the first line, we are importing xumm-sdk package. Next we create an instance of XummSdk, by passing XUMM application credentials.

Next we write a asynchronous function, which creates a child progress or a thread and waits for the response. Meanwhile the main thread or the main process continues to execute the code after it.

In above code, we simply output a message to the console window.

Note: By connecting to XUMM platform we can indirectly interact with XRP Ledger(XRPL).

For full “XUMM SDK/API” free video tutorial list visit: Working With XUMM SDK/API: XRPL

Get your XUMM API Credentials

To start working with XUMM SDK and API, the first thing you’ll need is application credentials. Application credentials are: App ID and App Secret, which you’ll get once you signup and register your application at apps.xumm.dev

Application Creation: XUMM Platform

xumm register application

All the application details can be modified later after creating the application, so need not stress too much to get it perfect the first time. You can even re-upload the application icon later on.

xumm create application

You can register multiple applications inside single xumm developer account. And you can also delete the registered application, by visiting the applications details page.

xumm delete application

Video Tutorial: Get your XUMM API Credentials


[youtube https://www.youtube.com/watch?v=tdoLbHiMTGo]

YouTube Link: https://www.youtube.com/watch?v=tdoLbHiMTGo [Watch the Video In Full Screen.]

Important Note

1. You can get App ID any time you log into your XUMM developer dashboard, but App Secret will be shown to you only once. i.e., when you create your application you’ll be shown the App Secret, after that it’ll be permanently hidden. You need to copy and paste it in safe place.

2. Please do not place your application credentials in client side code. These credentials are meant to be in server side code. If you place it in client side code, someone can get hold of it and use it for wrong things.

3. If you think your application credentials are compromised, then you can log into your xumm developer dashboard and generate a new one. Once you generate new App Secret, do not forget to replace the old one in your application.

4. Make sure to keep checking the LOGS and PAYLOADS section inside your XUMM developer dashboard.

xumm logs payloads dashboard

That’s where you’ll get valuable information about your program execution. Whenever you encounter a bug in your code, check the terminal output and then immediately check the LOGS and PAYLOADS section inside your XUMM developer account. It’ll have valuable information which can help you fix the issue sooner.

Note: Using your Application credentials you can connect to XUMM platform and then interact with XRP Ledger(XRPL) via XUMM SDK/API.

For full “XUMM SDK/API” free video tutorial list visit: Working With XUMM SDK/API: XRPL