2

I know I can use InitSpace to automatically calculate space for an account.

I know InitSpace doesn't include the Anchor discriminator, so I still to add another 8 bytes for the discriminator. I can add a constant for ANCHOR_DISCRIMINATOR_SIZE:

#[constant]
pub const ANCHOR_DISCRIMINATOR_SIZE: usize = 8;

But requiring every Anchor developer to create this constant, or use magic numbers, seems very odd. Is there an inbuilt constant for Anchor discriminator size?

1 Answer 1

1

I’ve looked through anchor’s repo.

There’s no any constant value written in the rust code to declare discriminator is 8 bytes long.

But in anchor’s TypeScript client there’s a constant value for DISCRIMINATOR_SIZE.

Maybe try opening up an issue in anchor’s repo they can help you more on this.

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.