node.js 获取以太坊合约事件

node.js 获取以太坊合约事件,第1张

合约项目开发中一些记录需要通过合约中的事件中获得,可以用thegraph第三方, 但是分页有问题无法获取总条数, 还需要科学上网,也可以用node.js,获取到数据存到数据库中,查询方便,在去中心化和中心化相结合的项目起到重要作用。

//  引入WEB3

const Web3 = require('web3')
const fs = require('fs')
const DB = require('./mysqlDB')
const BigNumber = require('bignumber.js')
let investSql = 'insert into invest (user,amount,backAmount,time,hash) values (?,?,?,?,?)'
let investSelectSql = 'select * from invest where hash=?'
let swapSql = 'insert into swap (user,usdtAmount,tokenAmount,time,swapType,hash) values (?,?,?,?,?,?)'
let swapSelectSql = 'select * from swap where hash=?'
let withdrawSql = 'insert into withdraw (user,amount,time,hash) values (?,?,?,?)'
let withdrawSelectSql = 'select * from withdraw where hash=?'
let intrologSql = 'insert into introlog (user,intro,rewordIndex,startTime,stopTime,rewardAmo

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/1319754.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-11
下一篇 2022-06-11

发表评论

登录后才能评论

评论列表(0条)

保存