I'd like to come up with the right memcmp
->offset
filter to be used with getProgramAccounts
. I am trying to query stake accounts associated with a voter
. I spent a bunch of time looking up the structs but cannot wrap my head around how the base58 data is structured. Thanks in advance
-
So some reverse engineering - found the offset is 124, but still would like to know where in the code I could see the structure of the logic that packs these– ArashCommented Aug 4, 2022 at 12:44
2 Answers
-
Will mark this as the answer, but I found an extremely helpful doc here too. solanacookbook.com/guides/get-program-accounts.html– ArashCommented Aug 23, 2022 at 22:31
The Anchor book has this great space reference, which gives a good guide on how much space each data type takes up:
https://book.anchor-lang.com/anchor_references/space.html
So once you know the types in the struct, and what order they're in (which is the same order as they appear in code), then you can work out the proper offset.
Keep in mind also that Anchor account types have an 8-byte discriminator up front before any data fields.
-
-
Ah, ok. It wasn't clear to me from the OP that the native stake program was the particular program in question. Commented Aug 24, 2022 at 15:10