DEV Community

Cover image for XUMM PYTHON SDK: 3. Your first payload πŸ””
Denis Angell
Denis Angell

Posted on

XUMM PYTHON SDK: 3. Your first payload πŸ””

Previous: 2. Prepare your project and start coding πŸ”¨

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:

  1. 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.
  2. 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.
  3. 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 token to deliver future sign requests using push notifications.
  4. 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: python3 playground.py. This should get you your very first XUMM sign request πŸŽ‰

Blog.3.1

Next:

4. Verify the results β›‘ and push πŸš€

5. Security & finishing touch πŸŽ‰

Resources πŸ“š

If you want to learn more about the XUMM SDK PY, platform, documentation, etc., make sure to check out:

The XUMM SDK (PY) readme
The XUMM SDK (PY) source code
The XUMM API documentation & API reference
XUMM (end user) support docs
In case of questions: support@xumm.app

Top comments (0)