kinda bump into an issue and not sure what's the problem. I wonder whether the instruction's parameter can be a Vec or an Array? for example:

# on-chain program
pub struct foo {
    a: u8,
    b: Pubkey,
    c: [u8; 32],

pub fn myfunction<'info>(
    ctx: Context<'info, MyCpiContext<'info>>,
    params: Vec<foo>,
) {...}

# client program
type foo {
   a: number,
   b: string,
   c: number[],
const param: foo[] = [...]
const ix = await this.client.program.methods

According to the example above, I not sure if I'm if there's syntax or logistic error. I keep getting TypeError: src.reduce is not a function error message while sending transaction to on-chain program.

1 Answer 1


Send the vec through in your instruction data, not in the account struct :)

#[instruction(a: u8, b: [u8;32)]
pub struct foo {
    b: PubKey

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.