2

Bear with me, I am a relative beginner.

I am implementing a Stellar SDK in R (not a standard SDK obviously) and I am at the stage where I need write functionality to build a transaction. I understand that the final transaction needs to be represented using XDR, but my question is what does XDR actually look like to a programmer who has never encountered it before?

My understanding is that it is probably one of two things:

  1. XDR is simply a way of serializing something. Similarly to how you can encode data into base64 and then into binary before sending it out onto the network, and when it is decoded on the other side it will be readable.

If this is true, and my choice of language supports it, I could serialize an in-memory object with code that might look something like this:

serialize(my_transaction_object, xdr = TRUE)

And then encode it into base64 and pass it in the body of a POST request to Horizon. But this seems like black magic to me.

  1. The transaction is sent as plain text, follows a set of rules, gets encoded with base64 and then transmitted to the network.

In my mind here, I feel like XDR would look something like this, just with extra data.I feel option 1 seems more likely to be correct. Am I missing something in my understanding?

Edit: clarified what I mean in option 2 with a link to an example.

Edit2: I'm also aware of this XDR viewer on the Stellar Laboratory. I guess I'm asking is how to represent the data in such a way that I can encode it as base 64 and the viewer will recognise it as a transaction.

1

Option 1 is correct. There is a serialisation layer used to pack the data into a strict format before base 64 encoding.

The XDR serde libraries used by the core SDKs are generated by running this code generator against the Stellar XDR specification.

I am not very familiar with R, but I can see on wikipedia that XDR is in some way native to R. Details are sketchy online, but you might have an easy pathway to integration.

Failing that, the easiest path to getting an R serde layer might be to add R support to the code generator. Or it may be to write it by hand from the spec files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.