Decode transaction blob

The hex of the transaction is


This is for version number 267361.

Where can I get the schema to be able to decode the transaction bytes?

1 Like

I’m assuming you are referring to the raw_txn_bytes field of a SignedTransaction? This is a representation of the proto serialized bytes of a RawTransaction object, so you need to use deserialize the proto bytes into a RawTransaction object


Yes that is correct. I will look into the RawTransaction object.

I am wondering the design decision for using raw bytes. It makes developing a lot more more difficult for consumers of the API. It also took me a while to deserialize AccountStateBlob to get something as simple as the account balance.

It’s actually something that we will possibly be changing soon. The reasoning for doing it this way is because the wallet needs to sign the transactions. Since proto isn’t canonical, the server cannot know the exact format that the client signed, so it needs the raw bytes to verify the signatures

I found an easy way to decode the transaction blob.
Create a new RawTransaction protobuf message object.
Deserialize using the helper from the protobuf Message subclass.

In PHP it’s ->mergeFromString($bytes). This function is named differently in different languages. In javascipt protobuf library it is .deserializeBinary()

@kph any idea to which codec are you going to switch? we use protobuf as well at IOV so far:

and yes protobuf is not canonical…

It’s likely that we will use the same canonical serialization that we use during consensus

could you pin point to the code?
What kind of serialization is it?
thank you @kph!

I’ll connect you with the people who are actively maintaining it and can give you better details

1 Like

Hi @antoineherzog,
About you question:
CanonicalSerialize for AccountResource