2

How to fetch the anchor discriminator in Typescript?

1 Answer 1

3

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

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.