Hi I am trying to test my contract in hardhat console. I am able to run my functions just fine but when I try to read a public global var it throws an error.
So for example:
uint256 public testVar;
function setInt(uint256 _intset) external {
testVar = _intset;
}
Then after successfully runnign await factory.setInt(123) in the console I run:
await factory.testVar()
But then for some reason I get the error message:
Error: call revert exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="testVar()", data="0x", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.6.3)
at step {
reason: null,
code: 'CALL_EXCEPTION',
method: 'testVar()',
data: '0x',
errorArgs: null,
errorName: null,
errorSignature: null,
address: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
args: [],
transaction: {
data: '0x9c328fb3',
to: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
from: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
gasLimit: BigNumber { value: "29021272" }
}
}
Any idea why i cannot simply get this public var?
Worth noting if i try run
await factory.testVar without the param it just says
[Function (anonymous)]
Thanks
To anyone in the future who is reading this. My problem was that in my hardhat config file I never configured my accounts:
So once I set:
accounts: [process.env.private_key]
It works fine.
WAGMI