I am trying to pass remaining_accounts from the client side using the Anchor SDK, with the following code.
const tx = await program.rpc.sendMonies(new anchor.BN(0), new anchor.BN(100), {
accounts: {
baseAccount: baseAccount.publicKey,
remainingAccounts: [
{pubkey: _ac1.publicKey, isWritable: true, isSigner: false},
{pubkey: _ac2.publicKey, isWritable: true, isSigner: false},
{pubkey: _ac3.publicKey, isWritable: true, isSigner: false}
],
user: payingUser.publicKey
},
signers: [payingUser]
});
Below is my program, where I log the number of remaining_accounts passed but, as you can see in the logs of this transaction the statement after "now transfer sol" logs 0. I even have a for-loop to iterate over the array of remaining accounts but that also doesn't run as the array is always empty.
msg!("now transfer sol");
msg!(ctx.remaining_accounts.len().to_string().as_str());
What am I doing wrong here? I highly suspect it is a problem with how I am passing the remaining accounts from the frontend.