获取全局var hardhat Console
嗨,我正在尝试在Hardhat Console测试我的合同。我可以很好地运行我的功能,但是当我尝试阅读公共全局var时,它会引发错误。
因此:例如:
uint256 public testVar;
function setInt(uint256 _intset) external {
testVar = _intset;
}
然后在成功运行的factory。setint(123)之后,在我运行的控制台中:
等待factory.testvar(),
但是由于某些原因,我会收到错误消息:
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" }
}
}
任何想知道为什么我不能简单地获得这个公共var?
值得注意的是,如果我尝试跑步
。
工厂
等待
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对将来阅读本文的任何人。我的问题是,在我的HardHat配置文件中,我从未配置过我的帐户:
因此,一旦设置:
它可以正常工作。
瓦格米
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:
It works fine.
WAGMI