One of the argument for my smart contract function is vec how do I pass this data type from my frontend using solana-web3js
1 Answer
you can pass them in the remaining_accounts
Remaining accounts given but not deserialized or validated. Be very careful when using this directly.
anchor
let accounts = ctx.remaining_accounts;
javascript
what you need is .remainingAccounts([])
const tx = await program.methods
.Initialize(new anchor.BN(10000000))
.remainingAccounts(
[{ pubkey: payer.publicKey, isWritable: false, isSigner: false }],
)
.accounts({
payer: payer.publickey,
systemProgram: anchor.web3.SystemProgram.programId,
tokenProgram: splToken.TOKEN_PROGRAM_ID,
})
.rpc();
console.log('Your transaction signature', tx);
});