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:
- 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.
- 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.