1

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:

trial_1

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

1 Answer 1

8

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

ctx.remaining_accounts
4

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.