2

how can i deocode the buffer data of account.

let pb = new PublicKey("GnAwACYKCx5LEv8QJUKvGigcix8AjnsrjLEn2Cu6UJrH")
   let a= await connection.getAccountInfo(pb)

Output Output

0

1 Answer 1

3

If you're using Anchor (which I recommend), you can use fetch to decode account data easily.

If you're not using Anchor you need to specify the structure and decode it using something like borsh.

Here is an example

const schema = new Map([[Test, { kind: 'struct', fields: [['x', 'u8'], ['y', 'u64'], ['z', 'string'], ['q', [3]]] }]]);

const newValue = borsh.deserialize(schema, decoded, buffer);

Example I wrote of decoding Metaplex Metadata

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.