How to fetch the anchor discriminator in Typescript?

1 Answer 1


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')

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .