6

One of the argument for my smart contract function is vec how do I pass this data type from my frontend using solana-web3js

0

1 Answer 1

3

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);
  });

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.