Error
var error = new Error(message);
^
Error: call revert exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="retrieve()", data="0x000000000000000000000000000000000000000000000000000000000000007b", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.7.0)
index.js
const { ethers } = require("ethers");
// const rpcUrl = "https://apothemxdcpayrpc.blocksscan.io/";
// const gorelirpcUrl = "https://eth-goerli.public.blastapi.io";
const infura = "https://goerli.infura.io/v3/";
const provider = new ethers.providers.JsonRpcProvider(infura);
const abi = ["function retrieve() view returns (unit256)"];
const contractAddress = "0xFc1135732B9f32D2785fE5B01a0936074993294A";
const newabi = [
'[{"inputs":[],"name":"get","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"num","type":"uint256"}],"name":"save","outputs":[],"stateMutability":"nonpayable","type":"function"}]',
];
const contract = new ethers.Contract(contractAddress, abi, provider);
const main = async () => {
const num = await contract.retrieve();
console.log(num);
};
main();
Storage.sol
/**
*Submitted for verification at Etherscan.io on 2022-05-07
*/
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/**
* @title Storage
* @dev Store & retrieve value in a variable
* @custom:dev-run-script ./scripts/deploy_with_ethers.ts
*/
contract Storage {
uint256 number;
/**
* @dev Store value in variable
* @param num value to store
*/
function store(uint256 num) public {
number = num;
}
/**
* @dev Return value
* @return value of 'number'
*/
function retrieve() public view returns (uint256){
return number;
}
}
It is not working it looks like a error
Thanks in Advance