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