Solidity:未找到标识符或标识符不唯一

时间:2021-06-22 05:39:45

标签: solidity openzeppelin

我正在阅读 OpenZeppelin 教程:https://docs.openzeppelin.com/learn/developing-smart-contracts?pref=truffle 并完全按照步骤操作。但是,在导入 Auth 合约后编译我的合约时,编译失败,并显示未找到标识符或不唯一。

这是我得到的错误: contract/Box.sol:10:5: DeclarationError: 标识符未找到或不唯一。 认证私人认证; ^--^

我的目录设置与教程完全一样,我在名为 access-control 的目录中有 Auth.sol 但它不起作用。

这是我要运行的代码:

// contracts/Box.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

// Import Auth from the access-control subdirectory
import "./access-control/Auth.sol";

contract Box {
    uint256 private value;
    Auth private auth;

    event ValueChanged(uint256 newValue);

    constructor(Auth _auth) public {
        auth = _auth;
    }

    function store(uint256 newValue) public {
        // Require that the caller is registered as an administrator in Auth
        require(auth.isAdministrator(msg.sender), "Unauthorized");

        value = newValue;
        emit ValueChanged(newValue);
    }

    function retrieve() public view returns (uint256) {
        return value;
    }
}

0 个答案:

没有答案