Now that we have established a connection to the XUMM platform using the XUMM SDK, it is time to actually send something that we can sign. We will send a "transaction template" to the XUMM platform, called a
Payload. The lifecycle of a payload is explained in more detail in the XUMM API documentation.
Some things to consider:
- A payload (sign request) sent to the XUMM platform should be formatted as per XRP ledger transaction specificaftions, but some fields may be omitted as XUMM will automatically fill them in if able to do so.
- Usually, a payload sent to the XUMM platform will be signed by the end user (e.g., for a sign in, subscription, payment, ...). For this tutorial, you will be the initiator and the end user, either signing or rejecting the payload.
- The first sign request from a specific XUMM app will always have to be scanned using a QR code on the desktop or redirected in the case of a smartphone. Once an end user trusts your application, by signing your request, your application can obtain a user specific
user tokento deliver future sign requests using push notificaftions.
- This tutorial is running on your own computer, from the terminal so we will need to copy then paste a sign request URL to our browser. In a real life application, a nicer flow for end users can be created with redirects / live status updates / push and fallback QR codes, etc.
Our first payload will be a
Payment transaction type. A basic
Payment payload you can send to the XUMM platform would be as per the following example:
If, like in the minimal example above, no amount is entered, the end user will be able to select the currency and amount to send in XUMM after opening the sign request. You could also add more details to your payload, as per the following example:
This sample specifies an amount in Drops (one XRP is one million Drops, the featured ten thousand drops represents 0.01 XRP) and a Memo (HEX encoded string). We will use this example in our code.
_Please change the destination account to an account that you own (remember to use your destination tag if this is required), or if you wish, you can test by sending a small amount of XRP to the XRPL Labs team by using the account in the example. _
We are going to use the
Sdk.payload.create() code to do this. We will provide two arguments to the
Sdk.payload.create(..., ...) code.
The first argument will be our payload (like in our previous example above) and in the second argument we will provide a flag (boolean,
true) telling the code to return an error, if one occurs.
Our code now looks like this:
Let's run the code. In the terminal panel, type the previously issued command to run our code:
node index.js. This should get you your very first XUMM sign request 🎉
If you want to learn more about the XUMM SDK, platform, documentation, etc., make sure to check out: