skka3134

skka3134

email
telegram

使用alchemy獲取最新的區塊

  1. 創建一個 'app',選擇測試網 goerli
    https://dashboard.alchemy.com/
    image
  2. 複製 apikey
    image
  3. 創建一個新的項目,並安裝 alchemy sdk
npm init
npm install alchemy-sdk
  1. 創建一個文件命名為 index.js,並添加代碼
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. 啟動!
node index.js

image

載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。