51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

ETH

6、web3.js 安装 ethereumjs-tx

6、web3.js 安装 ethereumjs-tx

厉飞雨 阅读(69) 评论(0) 赞(5)

web3.js 安装 ethereumjs-tx根据区块链工作原理,创建交易时,会签署交易然后向网络广播。为了签署交易,我们使用JavaScript库ethereumjs-tx。安装ethereumjs-tx库:$ npm install ethereumjs-tx使用这个库的目的是,可以在本地签署交易。要在本地签署交易,可以在本地运行自己的以太坊

23、web3.js underscore JS库

23、web3.js underscore JS库

厉飞雨 阅读(49) 评论(0) 赞(5)

web3.js underscore JS库Web3.js附带了underscoreJS库,可用于操作JavaScript数组或对象。示例app.jsconst Web3 = require('web3') const web3 = new Web3('https://mainnet.

22、web3.js sha3、keccack256、randomHex

22、web3.js sha3、keccack256、randomHex

厉飞雨 阅读(35) 评论(0) 赞(4)

web3.js sha3、keccack256、randomHexweb3.utils.sha3 – sha256哈希函数web3.utils.keccak256 – keccak256哈希函数web3.utils.randomHex – 生成十六进制随机数示例app.jsconst Web3 = require('web3') c

21、web3.js 查询平均 gas 价格

21、web3.js 查询平均 gas 价格

厉飞雨 阅读(24) 评论(0) 赞(5)

web3.js 查询平均 gas 价格查询平均gas价格,可以使用web3.eth.getGasPrice()函数。示例app.jsconst Web3 = require('web3') const web3 = new Web3('https://mainnet.infura.io

20、web3.js 查询区块中的交易

20、web3.js 查询区块中的交易

厉飞雨 阅读(42) 评论(0) 赞(6)

web3.js 查询区块中的交易要查询某个区块中的指定交易信息,可以使用web3.eth.getTransactionFromBlock(txHash, blockNum)函数。示例app.jsconst Web3 = require('web3') const web3 = new Web3

19、web3.js 查询指定区块

19、web3.js 查询指定区块

厉飞雨 阅读(43) 评论(0) 赞(5)

web3.js 查询指定区块要查询指定区块,可以使用web3.eth.getBlock()函数,可以指定区块的序号或哈希值。示例app.jsconst Web3 = require('web3') const web3 = new Web3('https://mainnet.infur

18、web3.js 查询最新区块

18、web3.js 查询最新区块

厉飞雨 阅读(35) 评论(0) 赞(5)

web3.js 查询最新区块要查询最新区块,可以使用web3.eth.getBlock('latest')函数。代码如下:app.jsconst Web3 = require('web3') const web3 = new Web3('https://mainnet.

17、web3.js 查询最新区块号

17、web3.js 查询最新区块号

厉飞雨 阅读(40) 评论(0) 赞(5)

web3.js 查询最新区块号要查询最新区块号,可以使用web3.eth.getBlockNumber()函数。代码如下:app.jsconst Web3 = require('web3') const web3 = new Web3('https://mainnet.infura.i

16、web3.js 执行事件查询

16、web3.js 执行事件查询

厉飞雨 阅读(55) 评论(0) 赞(6)

web3.js 执行事件查询完整代码如下:app.jsconst Web3 = require('web3') const web3 = new Web3('https://mainnet.infura.io/v3/YOUR_INFURA_API_KEY') //&n

15、web3.js 智能合约事件

15、web3.js 智能合约事件

厉飞雨 阅读(48) 评论(0) 赞(5)

web3.js 智能合约事件以太坊智能合约能够发出事件,表示在智能合约代码执行中发生的事情。智能合约的前端UI,例如,DApps、web3.js,都可以侦听这些事件。事件在区块链中的存储区块链是一个由区块组成的列表,这些块的内容基本上是交易记录。每个交易都有一个附加的交易日志,事件结果存放在交易日志里。合约发出的事件,可以使用合约地址访问。web3.js中,可以通过智能合约对象