Hi everyone, I've deployed a smart contract in a private network owned by the company I'm woking for. I have upgraded the smart contract by using this code:
// scripts/deploy_upgradeable_adminbox.js
import { ethers, upgrades } from 'hardhat';
const UPGRADEABLE_PROXY_ADDR = '0x4ED2156eB3881665c29792A9BA97Ce66D84070B8';
async function main() {
const ItemMarketplace = await ethers.getContractFactory('ItemMarketplace');
await upgrades.prepareUpgrade(
UPGRADEABLE_PROXY_ADDR,
ItemMarketplace,
{
kind: 'transparent'
}
);
const itemMarketplace = await upgrades.upgradeProxy(
UPGRADEABLE_PROXY_ADDR,
ItemMarketplace,
{
kind: 'transparent'
}
);
console.log(itemMarketplace);
console.log('Item marketplace upgraded');
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
I'm now trying to call a a function I just implemented:
function setRequireSupervision(uint256 _id, bool _newValue) public {
require(
msg.sender == itemByID[_id].owner,
"You don't own this item"
);
requiresLenderSupervision[_id] = _newValue;
emit ItemSupervisionModified(_id, _newValue);
}
This call fails with the following error:
> const trx = await contract.setRequireSupervision(1, true)
undefined
> await trx.wait()
Uncaught:
Error: transaction failed [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (transactionHash="0x85e286ea4050b970d956f1e2f60e09e2d983c2ae305cd750fefd28de5ca164e5", transaction={"hash":"0x85e286ea4050b970d956f1e2f60e09e2d983c2ae305cd750fefd28de5ca164e5","type":0,"accessList":null,"blockHash":null,"blockNumber":null,"transactionIndex":null,"confirmations":0,"from":"0x6A1dC2B9e7c24bABAF67983b2178a3636Eafd1c4","gasPrice":{"type":"BigNumber","hex":"0x00"},"gasLimit":{"type":"BigNumber","hex":"0x111d78"},"to":"0x4ED2156eB3881665c29792A9BA97Ce66D84070B8","value":{"type":"BigNumber","hex":"0x00"},"nonce":33,"data":"0x200f839900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001","r":"0x210921a6bb611c41e1cbc0f5d7a034f59beaa590da3d9e576471881fd22f2c69","s":"0x5b7492b4a8356bf6e4740045dce13afb66d90a13c91e2b8b7e2bcc8782061f3d","v":40442249,"creates":null,"raw":"0xf8a9218083111d78944ed2156eb3881665c29792a9ba97ce66d84070b880b844200f8399000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000018402691989a0210921a6bb611c41e1cbc0f5d7a034f59beaa590da3d9e576471881fd22f2c69a05b7492b4a8356bf6e4740045dce13afb66d90a13c91e2b8b7e2bcc8782061f3d","chainId":20221107}, receipt={"to":"0x4ED2156eB3881665c29792A9BA97Ce66D84070B8","from":"0x6A1dC2B9e7c24bABAF67983b2178a3636Eafd1c4","contractAddress":null,"transactionIndex":0,"gasUsed":{"type":"BigNumber","hex":"0x5b51"},"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","blockHash":"0xcffb8b06b3c7c8ebe37060ed3311809e3db5083e6195385f313da0fdbfff1b57","transactionHash":"0x85e286ea4050b970d956f1e2f60e09e2d983c2ae305cd750fefd28de5ca164e5","logs":[],"blockNumber":1741560,"confirmations":1,"cumulativeGasUsed":{"type":"BigNumber","hex":"0x5b51"},"effectiveGasPrice":{"type":"BigNumber","hex":"0x00"},"status":0,"type":0,"byzantium":true}, code=CALL_EXCEPTION, version=providers/5.7.2)
at step (/Users/nicolovanzo/Documents/work/commonshood/commonshood-contracts/node_modules/@ethersproject/providers/lib/base-provider.js:48:23)
at EthersProviderWrapper.<anonymous> (/Users/nicolovanzo/Documents/work/commonshood/commonshood-contracts/node_modules/@ethersproject/providers/src.ts/base-provider.ts:1549:24)
at Logger.throwError (/Users/nicolovanzo/Documents/work/commonshood/commonshood-contracts/node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
at Logger.makeError (/Users/nicolovanzo/Documents/work/commonshood/commonshood-contracts/node_modules/@ethersproject/logger/src.ts/index.ts:269:28) {
reason: 'transaction failed',
code: 'CALL_EXCEPTION',
transactionHash: '0x85e286ea4050b970d956f1e2f60e09e2d983c2ae305cd750fefd28de5ca164e5',
transaction: {
hash: '0x85e286ea4050b970d956f1e2f60e09e2d983c2ae305cd750fefd28de5ca164e5',
type: 0,
accessList: null,
blockHash: null,
blockNumber: null,
transactionIndex: null,
confirmations: 0,
from: '0x6A1dC2B9e7c24bABAF67983b2178a3636Eafd1c4',
gasPrice: BigNumber { value: "0" },
gasLimit: BigNumber { value: "1121656" },
to: '0x4ED2156eB3881665c29792A9BA97Ce66D84070B8',
value: BigNumber { value: "0" },
nonce: 33,
data: '0x200f839900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001',
r: '0x210921a6bb611c41e1cbc0f5d7a034f59beaa590da3d9e576471881fd22f2c69',
s: '0x5b7492b4a8356bf6e4740045dce13afb66d90a13c91e2b8b7e2bcc8782061f3d',
v: 40442249,
creates: null,
raw: '0xf8a9218083111d78944ed2156eb3881665c29792a9ba97ce66d84070b880b844200f8399000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000018402691989a0210921a6bb611c41e1cbc0f5d7a034f59beaa590da3d9e576471881fd22f2c69a05b7492b4a8356bf6e4740045dce13afb66d90a13c91e2b8b7e2bcc8782061f3d',
chainId: 20221107,
wait: [Function (anonymous)]
},
receipt: {
to: '0x4ED2156eB3881665c29792A9BA97Ce66D84070B8',
from: '0x6A1dC2B9e7c24bABAF67983b2178a3636Eafd1c4',
contractAddress: null,
transactionIndex: 0,
gasUsed: BigNumber { value: "23377" },
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
blockHash: '0xcffb8b06b3c7c8ebe37060ed3311809e3db5083e6195385f313da0fdbfff1b57',
transactionHash: '0x85e286ea4050b970d956f1e2f60e09e2d983c2ae305cd750fefd28de5ca164e5',
logs: [],
blockNumber: 1741560,
confirmations: 1,
cumulativeGasUsed: BigNumber { value: "23377" },
effectiveGasPrice: BigNumber { value: "0" },
status: 0,
type: 0,
byzantium: true
}
}
>
I have no idea why this is not working, it's insane.
EDIT: I've tried any other function and they also don't work
EDIT#2: So the old view functions actually work as intended. The newly created one does not. I got the bytecode of the deployed contract and its different than address(0) so there's something there! The ABIs are indeed correct, I checked them ten times.
EDIT#3: This is the error i get if I call any random testing() pure function I add after the update:
Uncaught:
Error: call revert exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="testing()", data="0x", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.7.0)
at step (/Users/nicolovanzo/Documents/work/commonshood/commonshood-contracts/node_modules/@ethersproject/contracts/lib/index.js:48:23)
at Contract.<anonymous> (/Users/nicolovanzo/Documents/work/commonshood/commonshood-contracts/node_modules/@ethersproject/contracts/src.ts/index.ts:400:44)
at Interface.decodeFunctionResult (/Users/nicolovanzo/Documents/work/commonshood/commonshood-contracts/node_modules/@ethersproject/abi/src.ts/interface.ts:427:23)
at Logger.throwError (/Users/nicolovanzo/Documents/work/commonshood/commonshood-contracts/node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
at Logger.makeError (/Users/nicolovanzo/Documents/work/commonshood/commonshood-contracts/node_modules/@ethersproject/logger/src.ts/index.ts:269:28) {
reason: null,
code: 'CALL_EXCEPTION',
method: 'testing()',
data: '0x',
errorArgs: null,
errorName: null,
errorSignature: null,
address: '0x5fA142e710d82f8C678f95843914864eBA1dC3fC',
args: [],
transaction: {
data: '0x8d03b102',
to: '0x5fA142e710d82f8C678f95843914864eBA1dC3fC',
from: '0x0b8d46bA2525a09981cB586888b02ffBd4353390'
}
}