0

I have responce from grpc

account {
  account {
    pubkey: "j\304\303\316\372\237\031\277T\310\334\017^M\034\356\3452}&H+)\322\261<\272\2444G!\215"
    lamports: 3648047
    owner: "\r\007Q\250(-\246\023\005\376)\2347\271\230\345\204q\333\0215\003s\020\370\276\020E\246\n\366\356"
    rent_epoch: 18446744073709551615
    data: "serum\003\000\000\000\000\000\000\000j\304\303\316\372\237\031\277T\310\334\017^M\034\356\3452}&H+)\322\261<\272\2444G!\215\001\000\000\000\000\000\000\000\006\233\210W\376\253\201\204\373h\177cF\030\3005\332\3049\334\032\353;U\230\240\360\000\000\000\000\001\306\372z\363\276\333\255:=e\363j\253\311t1\261\273\344\302\322\366\340\344|\246\002\003E/]a\250K\266FbFx\035z\232\332\270X\213\250k*\314\345\023X\310D\365DN@d\010u\375Z\000\341\023\231\215\007\000\000\000\000\000\000\000\000\000\000L\235\231}.\304;\334\r#bi\317\260\320\203\221\257\321\003\375\217\275cE?\365\213n#\251 \261U*\234v\000\000\000\357\334\252\307L\000\000\000d\000\000\000\000\000\000\000\251Ci\241\372a\214\226\003\031\311\233\025\352\212\203z~c[\027\200h\317\351|\353c\016\326\014\364k\02021\311u\005\014\354\215\246\336@5|\233\312`\357\236\2173\026Z%Vee*\202S;FRyI\340\247\246Y\370\252\334\206\274S\314|BF\232\027vZ\233\255b\261\260[\310h\265\356\311\276\271\261m\030\250\'9v\357\211\267\375\350J\354\233\252\312\r\261s\333\217\332J\340\336G\2124@B\017\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000i\360\242H\001\000\000\000padding"
    write_version: 1091844911179
    txn_signature: "*\371R\341\260m\t?\374\301\276.,\0314\001\007Q\210W+\242id#\205V\'(<\274\350x\361\007\372N\224\325\273eD\0168\013\367\266\366 \30542*\227v\344Pe\213/,U\366\013"
  }
  slot: 251475792
}

How decode data from "data" key of this responce SubscribeRequestFilterAccounts

txn_signature and pubkey I make human readeble by solders python method from_bytes

solana_public_key = Pubkey.from_bytes(account.pubkey)
signature = Signature.from_bytes(account.txn_signature)

Help please!

1 Answer 1

0

Accounts just store data as bytes based on the logic of the program that owns them, so it depends entirely on the owning program.

You can check the program id that owns the account, see if it's a well-known program (like the system program, stake program, SPL-token program, etc), and then deserialize it based on the schema of that program.

For Anchor programs that publish an IDL, you can fetch the IDL and interpret the bytes as that program would. I tried to find a simple example doing this at https://github.com/kevinheavey/anchorpy and failed to, so you might need to read up the tests to see how to put this together.

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.