skka3134

skka3134

email
telegram

Obtain the latest blocks using alchemy.

  1. Create an 'app' and select the Goerli test network.
    https://dashboard.alchemy.com/
    image
  2. Copy the API key.
    image
  3. Create a new project and install the Alchemy SDK.
npm init
npm install alchemy-sdk
  1. Create a file named index.js and add the following code:
const { Network, Alchemy } = require("alchemy-sdk");
const settings = {
  apiKey: "wEDkV89fbvvsbplG8oYhrwnOYG8c3M-C",
  network: Network.ETH_GOERLI,
};
const alchemy = new Alchemy(settings);
async function main() {
  const latestBlock = await alchemy.core.getBlockNumber();
  console.log("The latest block number is", latestBlock);
}
main();
  1. Start the application!
node index.js

image

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.