1

I assume that there is a naming scheme being used for the account state discriminators as seen here in the token metadata extension

    const SPL_DISCRIMINATOR: ArrayDiscriminator =
        ArrayDiscriminator::new([112, 132, 90, 90, 11, 88, 157, 87]); 

My questions are:

  1. Whether the slice is chosen randomly or if there's meaning to each value in said slice.

  2. Why an array discriminator as opposed to a hashed constant string value?

1 Answer 1

1

The discriminator actually is calculated with a hash! You can see the test for it at https://github.com/solana-labs/solana-program-library/blob/57bc2457827775b3299fa9efc02ce7e50d34135f/token-metadata/interface/src/state.rs#L131-L136

The spl-discriminator library was very new at the time, and didn't have the ability to use a macro to create a discriminator, but now it's possible to do something like:

    #[derive(SplDiscriminate)]
    #[discriminator_hash_input("global:my_instruction_with_one_generic_and_lifetime")]
    pub struct MyInstruction5<'b, T> {
        data: &'b [T],
    }

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.