web3.eth.accounts 返回 undefined

web3.eth.accounts 返回 undefined,第1张

文章目录 `web3.eth.accounts` 返回 undefined

web3.eth.accounts 返回 undefined

错误:

truffle(develop)> web3.eth.accounts[0]
undefined

web3.eth.accounts 已被弃用

最新版本v1.5.2 可以这么写

web3.eth.getAccounts().then(function(acc){ accounts = acc })
accounts[0]

控制台:

truffle(develop)> web3.eth.getAccounts().then(function(acc){ accounts = acc })
undefined
truffle(develop)> accounts[0]
'0x95886D9241c643E6963C4F450779B9b0A974B8C7'
truffle(develop)> accounts[1]
'0xfb5e22Dbc4E1781288402742591ee4dB9E421F27'

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

原文地址: https://www.outofmemory.cn/zaji/1319915.html

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

发表评论

登录后才能评论

评论列表(0条)

保存