1

I am trying to send a solana transaction with the web3js library.

I tried both functions

web3.sendConfirmTransaction(connection,transaction,[signers])

and by sending raw transaction after I sign the transaction with :

transaction.sign() 
web3.SendConfirmRawTransaction(connection,transaction.serialise()) 

but I keep getting errors saying transaction verification failed. by tracking the error, the second signature in the signatures array is null that's what is generating the error. anyone can help !!

Ray
  • 47
  • 3

1 Answers1

1

Assuming that signers is an array of Keypairs that can sign, you should instead do:

web3.sendConfirmTransaction(connection, transaction, signers)

And

connection.sendTransaction(transaction, signers); 

sendTransaction will take care of fetching the blockhash, signing the transaction, serializing, and sending.

Jon C
  • 7,019
  • 10
  • 17
  • thanks for your reply 1-sorry i didn't mentioned that i am trying to buy an NFT from marketplace 2- signers I only have my own keypair, not the marketplace keypair 3-web3.sendConfirmTransaction and connection.sendTransaction aren't the same? the difference in the confirmation the first will be confirmed automatically and the second I have to do the confirmation after sending transaction right ? – Ray Jul 25 '22 at 14:11
  • Yep that's correct -- your best bet is to just read the source code! Here's `sendAndConfirmTransaction` https://github.com/solana-labs/solana/blob/master/web3.js/src/util/send-and-confirm-transaction.ts and here's `sendTransaction` https://github.com/solana-labs/solana/blob/5d038b9d2a53723daef02c75ef979f45e2cd90f7/web3.js/src/connection.ts#L4456 – Jon C Jul 25 '22 at 19:28