0

I am trying to call a function using a non-anchor program from solana. The function takes a [u8:32] argument as "seeds" and a u32 argument as "number_of_schedules". I have looked all over the docs online and no information on this is available, or they only show how to encode basic data like instruction index. Here is my layout:


  const dataLayout = BufferLayout.struct([
    BufferLayout.u8('instruction'),
    BufferLayout.u32('seeds'), // I don't think this is right; should be [u8; 32] but can't find that
    BufferLayout.u32('number_of_schedules')
  ]);
  const data = Buffer.alloc(dataLayout.span);
  dataLayout.encode(
    {
      instruction: 0, // 0 for create instruction,
      seeds: seeds,
      number_of_schedules: new BN(3),
    },
    data,
  );

please help me

1
  • Is my answer below what you needed, @Lola1222? If so, click that ‘accept’ checkmark, when you have a chance. Commented Nov 14 at 17:30

1 Answer 1

1

An array of fixed length can be expressed as follows:

BufferLayout.seq(BufferLayout.u8('seed'), 32, 'seeds')

A sequence (labelled 'seeds') of u8 elements (labeled 'seed'), of length 32.

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.