Closed paulvi closed 3 years ago
Hi @paulvi,
I’m sorry that you had this issue.
Unfortunately, I wasn’t able to reproduce this issue. I tried the following:
// contracts/Box.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
contract Box {
uint256 private value;
// Emitted when the stored value changes
event ValueChanged(uint256 newValue);
// Stores a new value in the contract
function store(uint256 newValue) public {
value = newValue;
emit ValueChanged(newValue);
}
// Reads the last stored value
function retrieve() public view returns (uint256) {
return value;
}
}
// contracts/BoxV2.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
contract BoxV2 {
uint256 private value;
// Emitted when the stored value changes
event ValueChanged(uint256 newValue);
// Stores a new value in the contract
function store(uint256 newValue) public {
value = newValue;
emit ValueChanged(newValue);
}
// Reads the last stored value
function retrieve() public view returns (uint256) {
return value;
}
// Increments the stored value by 1
function increment() public {
value = value + 1;
emit ValueChanged(value);
}
}
$ npx hardhat run --network localhost scripts/deploy_upgradeable_box.js
Compiling 2 files with 0.7.3
Compilation finished successfully
Deploying Box...
Box deployed to: 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
The Learn guide uses Box.sol
with a contract named Box
and BoxV2.sol
named BoxV2
.
It looks like your contract in BoxV2.sol
is named Box
rather than BoxV2
. Can you try renaming this to BoxV2
Thank you so much, it was all mine error
The warning by tool is correct, I had BoxV2 file not fully updated. (It had Box inside )
The page at https://docs.openzeppelin.com/learn/upgrading-smart-contracts
says to use
However when there is also
BoxV2.sol
is added, as suggested later on the page, this script now fails:Please suggest
deploy_upgradeable_box.js
that would work regardless of what are other files incontracts/
P.S. using file name as
await ethers.getContractFactory("Box.sol");
fails with the same error.doc source is at: https://github.com/OpenZeppelin/docs.openzeppelin.com/blob/master/components/learn/modules/ROOT/pages/upgrading-smart-contracts.adoc