How to fetch the anchor discriminator in Typescript?
1 Answer
You can use this function to fetch the Anchor Discriminator in Typescript.
function sighash(nameSpace: string, ixName: string): Buffer {
let name = snakeCase(ixName);
let preimage = `${nameSpace}:${name}`;
return Buffer.from(sha256.digest(preimage)).slice(0, 8);
}
Example Instruction
const ixBuffer = sighash('global','initialize')