Problem:
When using older versions of @solana/web3.js (such as 1.33.0), the following error occurs:
"failed to get recent blockhash: Method not found at Connection.getRecentBlockhash"
This error is caused by the removal of the getRecentBlockhash method in Solana RPC, which older versions of @solana/web3.js attempt to call.
Solution:
Upgrade @solana/web3.js to version ^1.98.0, which resolves the error by using the updated getLatestBlockhash method in the Solana RPC.
Steps to Reproduce:
- Use an older version of
@solana/web3.js (e.g., 1.33.0).
- Attempt to send a transaction using
sendAndConfirmTransaction.
- Receive the error:
failed to get recent blockhash: Method not found.
https://www.quicknode.com/docs/solana/getRecentBlockhash