1

For signing transactions, there is only one account (provider.wallet). I have written a program and it has some authority access functions, how can I use multiple accounts to check it? If I generated new ones they gave me signature verification failed error..

2 Answers 2

1

Most likely your additional keypairs have no SOL to pay for tx fees. You can request an airdrop for them as follows:

const wallet = anchor.web3.Keypair.generate();

const tx = await connection.requestAirdrop(
    wallet.publicKey,
    anchor.web3.LAMPORTS_PER_SOL * 1
  );

const latestBlockHash = await connection.getLatestBlockhash();
await connection.confirmTransaction({
    blockhash: latestBlockHash.blockhash,
    lastValidBlockHeight: latestBlockHash.lastValidBlockHeight,
    signature: tx
});

After this, you should be able to sign & pay for transactions with these keypairs.

1

Generate wallet address and make airdrop remove rpc() from function calls and use solana/web3.js methods

const wallet = anchor.web3.Keypair.generate()

const tx = await connection.requestAirdrop(
    wallet.publicKey,
    anchor.web3.LAMPORTS_PER_SOL * 1
  );

const latestBlockHash = await connection.getLatestBlockhash();
await connection.confirmTransaction({
    blockhash: latestBlockHash.blockhash,
    lastValidBlockHeight: latestBlockHash.lastValidBlockHeight,
    signature: tx
});

    const tx = await prog.methods
      .func()
      .accounts({ account: wallet.publicKey })
      .signers([wallet])
      .transaction();
    await sendAndConfirmTransaction(prog.provider.connection, tx, [wallet])

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.