Open ghost opened 2 years ago
Sure, I'd be happy to help! Here's how you can replace getRecentBlockhash
with getLatestBlockhash
:
web3.js
library:const Web3 = require('web3');
Web3
class:const web3 = new Web3('https://api.mainnet-beta.solana.com');
getRecentBlockhash
with getLatestBlockhash
:const blockhash = await web3.eth.getLatestBlockhash();
That's it! This should replace all instances of the deprecated getRecentBlockhash
with the new getLatestBlockhash
. Let me know if you have any questions or if there's anything else I can help you with.
Sure, here's an example of how you can replace getRecentBlockhash
with getLatestBlockhash
:
Before:
const connection = new Connection(url, 'confirmed');
const recentBlockhash = await connection.getRecentBlockhash();
After:
const connection = new Connection(url, 'confirmed');
const recentBlockhash = (await connection.getLatestBlockhash('recent')).blockhash;
Note that getLatestBlockhash
returns an object containing the blockhash and the fee calculator. In this example, we're accessing the blockhash
property of the returned object. Also, the 'recent'
parameter specifies that we want the most recent blockhash. You can replace it with a specific slot number if needed.
note: replace the deprecated getRecentBlockhash with the new getLatestBlockhash context: https://twitter.com/GenesysGo/status/1508296004398948357