Skip to main content
3 votes
Accepted

Decode account data

I found the answer. Instead of using: import { publicKey, u64, bool, u256, u128 } from '@solana/buffer-layout-utils'; import { u32, u8, struct} from '@solana/buffer-layout'; I used: import * as borsh ...
CryptoTioSam's user avatar
2 votes

Decoding data buffer of an account - @solana/buffer-layout - Rust u64 to Typescript Number conversion

Did you know that the Buffer has convenient methods to read numbers? for instance you could use readBigInt64LE for the supply like this: let supply = usdcAcctInfo.data.readBigInt64LE(36); Then you ...
Solandy's user avatar
  • 511
2 votes
Accepted

What's the difference of using Borsh and buffer layout to encode/decode?

Borsh is just a particular serialization format, given by the spec at https://borsh.io/. They also provide libraries for serializing and deserializing types based on that spec. Buffer layout is a JS ...
Jon C's user avatar
  • 19.6k
1 vote
Accepted

How to use a CString with a custom program?

The size of a string in C is roughly "keep going until you see a 0 byte", which doesn't work when you need to know the exact size. This is why you're seeing an error. You must pre-allocate ...
Jon C's user avatar
  • 19.6k

Only top scored, non community-wiki answers of a minimum length are eligible