It seems that you are facing an issue with retrieving the latest block hash from the Solana Blockchain in a vanilla JavaScript mini app using HTML and AJAX with a CDN.

The error message “Method not found Connection.getRecentBlockhash in vanilla javascript” indicates that the Connection object does not have a method called “getRecentBlockhash”, which is likely due to a compatibility issue or an outdated library.

Here is an article that should help you resolve this issue:

Unable to retrieve latest block hash from Solana Blockchain in Vanilla JavaScript Mini app

Error message:

Method not found Connection.getRecentBlockhash in vanilla javascript

Solution:

Here is an example:

const connection = new Web3Connection(url); // Change the URL of your Solana wallet

async function getRecentBlockhash() {

const recentHash = await connection.getRecentBlockhashAsync();

return latestHash;

}

Code example:

Solana Lottery

CDN Setup:

If you are using a CDN, be sure to add the following script tag to your HTML: