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);
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 enter image description here

  • the call exception might be because you're trying to access an element of the array which is out of bounds? I.e. have you "pushed" entries to the array?
    – phaze
    Jun 22, 2022 at 14:45
  • thanks for your reply, and yes it's filled at initialization.
    – Peko Chan
    Jun 22, 2022 at 14:54
  • no @ruby_newbie , tiers is an array but as it is declared as public, it automatically creates a getter so that there is a function basically doing that: function tiers(uint256 index) public view returns (uint256) { return thiers[index]; }
    – Franfran
    Jun 22, 2022 at 17:11

1 Answer 1


In my case, it was caused by wrong RPC url, you should consider this case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.