I am trying to fetch data on public variables from the blockchain using ethers.js.
but other declared functions will work properly.
This is the way I am using it.
My solidity:
contract NLTNFT is ERC1155, Ownable {
uint256[] public tiers;
uint256 public maxPerWallet;
constructor() ERC1155('https://nlt.rocks/metadata/{id}.json'){
tiers = [0, 1, 2];
maxPerWallet = 3;
}
}
My JS ethers.js:
const contract = new ethers.Contract(nltContractAddress, NLTNFT.abi, signer);
//then
const res = await contract.tiers(1);
// or
const res2 = await contract.maxPerWallet();
in both case this is what I get:
err: Error: call revert exception (method="tiers(uint256)", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.2.0)
at Logger.makeError (ethers-5.2.umd.min.js:1:59669)
at Logger.throwError (ethers-5.2.umd.min.js:1:59874)
at Interface.decodeFunctionResult (ethers-5.2.umd.min.js:1:206132)
at Object.<anonymous> (ethers-5.2.umd.min.js:1:311725)
at step (ethers-5.2.umd.min.js:1:305047)
at Object.next (ethers-5.2.umd.min.js:1:304307)
at fulfilled (ethers-5.2.umd.min.js:1:303681)
here is a remix screenshot
all the orange feature I can get from JS all the blue I can't
function tiers(uint256 index) public view returns (uint256) { return thiers[index]; }