I'm writing an escrow program for multiple assets in one swap. I was trying an effective way to input token mint & token accounts. So I tried using Vec<> as following but it poped up the following error:


Is there a solution to Vec<> error or an effective way to input multiple accounts?

1 Answer 1


No, you can only use the remaining_accounts functionality for adding a variable length number of accounts.

From one of the misc code examples in the anchor repo, this is how you can add a vector of remaining accounts with the ts library.

    await program.state.rpc.remainingAccounts({
      remainingAccounts: [
        { pubkey: misc2Program.programId, isWritable: false, isSigner: false },

You can access them inside the program function with


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.