【问题标题】:"Cannot read property 'utils' of undefined" on web3.utils\“无法读取属性 \'utils\' of undefined\” on web3.utils
【发布时间】:2022-08-16 00:02:32
【问题描述】:

这是我的代码:

import {web3} from \"hardhat\"


const OWNER_ROLE = web3.utils.keccak256(\"OWNER_ROLE\");

这是我终端中的错误:

const OWNER_ROLE = web3.utils.keccak256(\"OWNER_ROLE\");
                        ^
TypeError: Cannot read property \'utils\' of undefined

标签: ethereum solidity hardhat


【解决方案1】:

您需要在项目中安装 nomiclabs-hardhat-web3 库。

https://hardhat.org/hardhat-runner/plugins/nomiclabs-hardhat-web3

【讨论】:

    猜你喜欢
    • 2018-02-26
    • 1970-01-01
    • 2020-01-24
    • 2021-07-08
    • 2019-07-19
    • 2020-08-08
    • 1970-01-01
    • 2019-09-01
    • 2023-03-04
    相关资源
    最近更新 更多