小编Pal*_*alm的帖子

错误:Truffle 当前使用 solc 0.5.16,但您的一个或多个合约指定“pragma Solidity ^0.8.0”

错误:Truffle 当前使用 solc 0.5.16,但您的一个或多个合约指定 \xe2\x80\x9cpragma Solidity ^0.8.0\xe2\x80\x9d

\n

这是错误的照片 - https://gyazo.com/2f5ea2f50cc1d4ef5eea2f21d0e04fe7

\n

我的所有合约都使用 ^0.8.0 编译指示。我的 truffle-config 也使用与您在此处看到的相同的版本 -https://gyazo.com/1ec8b28ca48902c091004f8659cf678d

\n

请帮忙。非常感谢。

\n

blockchain ethereum solidity smartcontracts truffle

11
推荐指数
1
解决办法
7752
查看次数

未找到所请求的合同。确保源代码可用于编译

我正在使用“@openzeppelin/truffle-upgrades”插件来创建可升级的合同。第一次这样做,并以他们在网站上的文章为基础。https://docs.openzeppelin.com/learn/upgrading-smart-contracts

一切都编译正确,但每当我迁移“未找到所请求的合同。确保源代码可用于编译”时,3_deploy_upgradeable_box.js 就会吐出​​此错误,或者查看此屏幕截图https://gyazo.com/f4b8d8afea69b67965670b520e48db13

这是我的代码

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

import "@openzeppelin/contracts/access/Ownable.sol";

contract Box is Ownable {

    uint256 private value;

    // Emitted when the stored value changes
    event ValueChanged(uint256 _value);

    // Store a new value in the contract, only the owner can call this
    function store(uint256 _value) public onlyOwner {
        value = _value;
        emit ValueChanged(_value);
    }

    // Retrieve the last stored value
    function retrieve() public view returns(uint256) {
        return value;
    }

}
Run Code Online (Sandbox Code Playgroud)
// migrations/2_deploy.js
const Box …
Run Code Online (Sandbox Code Playgroud)

javascript ethereum solidity openzeppelin

5
推荐指数
1
解决办法
2148
查看次数