Joe*_*son 4 javascript ethereum solidity truffle ganache
当我执行“松露部署”命令时,我突然开始收到“部署时迁移遇到无效操作码”错误。
\n我的迁移文件没有更改,所以我不确定为什么突然收到此错误。每个发布相同错误的人都只是建议下载最新版本的 ganache/truffle,但我已将我的 truffle 和 ganache 更新到最新版本,但仍然收到错误。
\n\n\n网络名称:'development'\n网络 ID:5777\n区块 Gas 限制:6721975 (0x6691b7)
\n
*** 从 solc-bin 部署***失败。尝试#1
\n“迁移”在部署时遇到无效的操作码。尝试:
\n退出:通过在 Etherscan 上检查上面的交易哈希值来手动查看成功的交易。
\n错误:*** 部署失败 ***
\n“迁移”在部署时遇到无效的操作码。尝试:
\nat /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:330:1\nRun Code Online (Sandbox Code Playgroud)\nTruffle v5.9.2(核心:5.9.2)\nNode v18.7.0
\n迁移.sol
\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.9;\n\ncontract Migrations {\n address public owner;\n uint256 public lastCompletedMigration;\n\n constructor() {\n owner = msg.sender;\n }\n\n modifier restricted() {\n require(msg.sender == owner, "Restricted to contract owner");\n _;\n }\n\n function setCompleted(uint256 completed) public restricted {\n lastCompletedMigration = completed;\n }\n\n function upgrade(address new_address) public restricted {\n Migrations upgraded = Migrations(new_address);\n upgraded.setCompleted(lastCompletedMigration);\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n1_initial_migration.js
\nconst Migrations = artifacts.require("Migrations");\n\nmodule.exports = function(deployer) {\n deployer.deploy(Migrations);\n};\nRun Code Online (Sandbox Code Playgroud)\n
小智 9
尝试更改您的 pragma 和 solc 版本
迁移.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
Run Code Online (Sandbox Code Playgroud)
truffle-config.js
compilers: {
solc: {
version: "0.5.1"
}
Run Code Online (Sandbox Code Playgroud)
有时,solc 适用于 0.8.20 或 0.7.3
| 归档时间: |
|
| 查看次数: |
6288 次 |
| 最近记录: |