我会把它放在堆栈溢出上,但它特定于黑客马拉松。这是针对 HardHat 教程的。我正在尝试在我的智能合约上执行我的 get-number 功能。我的合同已部署。这是我的命令:npx hardhat get-number --contract 0x5FbDB2315678afecb367f032d93F642f64180aa3。这是我得到的错误:错误:调用还原异常(method="getNumber()",errorArgs=null,errorName=null,errorSignature=null,reason=null,code=CALL_EXCEPTION,version=abi/5.5.0)。任何想法都会有所帮助...谢谢。
这是任务
task("get-number", "Reads the number")
.addParam("contract", "The contract's address")
.setAction(async (taskArgs) => {
const contractAddr = taskArgs.contract;
const MyFirstContract = await ethers.getContractFactory('MyFirstContract');
const accounts = await ethers.getSigners();
const signer = accounts[0];
const myFirstContract = await new ethers.Contract(contractAddr, MyFirstContract.interface, signer);
let result = BigInt(await myFirstContract.getNumber()).toString();
console.log('Stored number is: ' + result);
});
module.exports = {};