编程好6文档

  • 首页
  • 人工智能
  • DevOps
  • 区块链
  • 前言技术
  • 编程好6博客
  • jb激活码汇总

  • 首页
  • 人工智能
  • DevOps
  • 区块链
  • 前言技术
  • 编程好6博客
  • jb激活码汇总

目录

  • web3.js 介绍
  • web3.js – underscore JS库
  • web3.js – 执行交易
  • web3.js 下载安装
  • web3.js 交易小结
  • web3.js 准备智能合约
  • web3.js 准备账号
  • web3.js 哈希函数
  • web3.js 安装ethereumjs-tx
  • web3.js 执行事件查询
  • web3.js 执行写函数调用
  • web3.js 执行部署
  • web3.js 智能合约事件
  • web3.js 智能合约对象
  • web3.js 查询区块中的交易
  • web3.js 查询平均gas价格
  • web3.js 查询指定区块
  • web3.js 查询最新区块号
  • web3.js 访问区块链网络
  • web3.js 调用智能合约写函数
  • web3.js 调用智能合约读函数
  • web3.js 部署智能合约
web3.js 查询指定区块
web3.js 访问区块链网络

web3.js 查询最新区块号



web3.js 查询最新区块号

要查询最新区块号,可以使用
web3.eth.getBlockNumber()函数。
代码如下:
app.js
const Web3 = require('web3')
const web3 = new Web3('https://mainnet.infura.io/v3/YOUR_INFURA_API_KEY') // YOUR_INFURA_API_KEY替换为你自己的key
// 查询最新区块
web3.eth.getBlockNumber().then(console.log)

运行app.js:
$ node app

输出
8718170


web3.js 查询指定区块
web3.js 访问区块链网络
Copyright © 2023 bianchenghao6.com 晋ICP备19011774号