Follow the author’s @abcoathup steps (OpenZeppelin Truffle Upgrades: Step by Step Tutorial) and everything is OK . but if Box2V is inherited from Box, problem occurs . modify the BoxV2 to:
// contracts/BoxV2.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "./Box.sol";
contract BoxV2 is Box{
// Increments the stored value by 1
function increment() public {
value = value + 1;
emit ValueChanged(value);
}
}
Then run: npx truffle migrate,An error occurred
===============
2_deploy_box.js
Error: Artifacts are from different compiler runs
Run a full recompilation using `truffle compile --all`
https://zpl.in/upgrades/truffle-recompile-all
at reconstructSolcInputOutput (E:\work\eth\oz\node_modules\@openzeppelin\truffle-upgrades\src\validate.ts:61:15)
at Object.validateArtifacts (E:\work\eth\oz\node_modules\@openzeppelin\truffle-upgrades\src\validate.ts:14:29)
at deployProxy (E:\work\eth\oz\node_modules\@openzeppelin\truffle-upgrades\src\deploy-proxy.ts:28:23)
at module.exports (E:\work\eth\oz\migrations\2_deploy_box.js:14:3)
at Migration._deploy (E:\work\eth\oz\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:73:1)
at Migration._load (E:\work\eth\oz\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:55:1)
at Migration.run (E:\work\eth\oz\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:171:1)
at Object.runMigrations (E:\work\eth\oz\node_modules\truffle\build\webpack:\packages\migrate\index.js:150:1)
at Object.runFrom (E:\work\eth\oz\node_modules\truffle\build\webpack:\packages\migrate\index.js:110:1)
at Object.run (E:\work\eth\oz\node_modules\truffle\build\webpack:\packages\migrate\index.js:87:1)
at runMigrations (E:\work\eth\oz\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:269:1)
at E:\work\eth\oz\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:231:1
Truffle v5.1.45 (core: 5.1.45)
Node v12.18.4
I feel this problem occurs if BoxV2.sol contains import .
my env:
Truffle v5.1.45 (core: 5.1.45)
Solidity - 0.7.0 (solc-js)
Node v12.18.4
Web3.js v1.2.1
Please help to solve the problem, thank you very much.