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 ...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
buffer-layout × 6deserialization × 3
account-data × 2
solana-program × 1
keypair × 1
typescript × 1
dex × 1
buffer × 1
borsh × 1
serialization × 1
decode × 1
serum × 1
web3.js × 1
offset × 1
raydium × 1