1. 创建一个‘’app‘’,选择测试网 goerli
https://dashboard.alchemy.com/
2. 复制 apikey
2. 创建一个新的项目,并安装 alchemy sdk
npm init
npm install alchemy-sdk
3. 创建一个文件命名为 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();
4. 启动!
node index.js