AccountInfo data decoding #378
-
Good evening, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Taken from #140, an old reply. This depends on the kind of object you're trying to decode but here's a general idea of what to do to try and decode the data: First and foremost decode the data from base64 into a To add more context to this, the v0.3.1 release featured additions of utility methods that can be used to make encoding and decoding of program and account data much easier, the implementations of SPL and Native programs inside They should make the program and account data encoding and decoding much cleaner and easy to implement, they are also open to additions :) |
Beta Was this translation helpful? Give feedback.
Taken from #140, an old reply.
This depends on the kind of object you're trying to decode but here's a general idea of what to do to try and decode the data:
First and foremost decode the data from base64 into a
byte[]
aSpan<byte>
or whatever your preferred type for this is going to be, you can check some examples of this being done in the Serum code, or the Mango or Solend onesAfterwards, it depends on the type of account you're trying to decode, certain accounts will have a certain data layout, i.e. Serum Market accounts have a certain layout (Serum Market account layouts), and they have to be decoded according to that layout, by using offsets and reading the desired data type for the…