2

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

1
  • 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
    – Arash
    Commented Aug 4, 2022 at 12:44

2 Answers 2

0

The native stake program's top-level state type is declared here. It's serialized using bincode

1
1

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.

2
  • the native stake program does not use anchor
    – trent.sol
    Commented Aug 19, 2022 at 7:00
  • Ah, ok. It wasn't clear to me from the OP that the native stake program was the particular program in question.
    – HelmetFace
    Commented Aug 24, 2022 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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