Web3.js 报错:Uncaught TypeError: web3.sha3 is not a function

2 篇文章 1 订阅
2 篇文章 0 订阅

web3.js 报错:Uncaught TypeError: web3.sha3 is not a function

truffle(develop)> var hash = web3.sha3("Some string to be hashed");
evalmachine.<anonymous>:0
var hash = web3.sha3("Some string to be hashed");
                ^

Uncaught TypeError: web3.sha3 is not a function
    at evalmachine.<anonymous>
    at sigintHandlersWrap (node:vm:268:12)
    at Script.runInContext (node:vm:137:14)
    at runScript (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:364:1)
    at Console.interpret (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:379:1)
    at bound (node:domain:421:15)
    at REPLServer.runBound [as eval] (node:domain:432:12)
    at REPLServer.onLine (node:repl:889:10)
    at REPLServer.emit (node:events:394:28)
    at REPLServer.emit (node:domain:475:12)

看到此错误先在控制台输入:web3.version 检查下web3.js版本

truffle(develop)> web3.version
'1.5.2'

1.5.2版本已经不再支持这种写法,换成如下写法:

var str = web3.utils.sha3("Some string to be hashed");
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值