I am currently writing a frontend for my custom on-chain program. The frontend is supposed to take input from a form and then submit the data to the program. Currently I'm following this tutorial (https://docs.solana.com/developing/clients/javascript-api#interacting-with-custom-programs) to write the frontend code.
The issue I'm running into is in composing my struct for the layout of the transaction. My struct is created thusly:
let starshipStruct = {
index: 1,
layout: struct([
u32('instruction'),
cstr('container'),
u16('hours'),
]),
};
When I attempt to allocate a Buffer for this struct, I receive an error that the size cannot be -1. I've determined the issue is with the cstr
function which is returning a value of -1. How would one set the size for this function? I'm using the @solana/buffer-layout
library for these functions. Thanks in advance!