as the title suggest, Im trying to call PSP22 token contract and read balanceOf() function, but i get error that im passing a too big of a input (27 instead of 8) Im trying to invoke balanceOf() PSP22 ink! contract.

When i initializing the token it works correctly and i can see the abi:

alanceOf: function createQuery(origin, options)
length: 2
meta: Object { isMutating: false, isPayable: false, identifier: "balance_of", … }
args: Array [ {…} ]
0: Object { name: "owner", type: {…} }
name: "owner"
type: Object { info: 10, type: "AccountId" }

Here is the code:

    const tokenContract = new ContractPromise(api, abiToken, "5FmJDyLBoYKfiaoPUcfR3WKh13HkwvXr2CYTNg5RLykNXY3A");
    const value = 0; // only useful on isPayable messages
    // NOTE the apps UI specified these in mega units
    const gasLimit = 3000n * 1000000n;

    // (We perform the send from an account, here using Alice's address)
    let alice = "5DaYseV9GSrGKrJYmKU5yymF9izPM2ZzG8f93xQK6hectHuo"
    const { gasConsumed, result, output } = await tokenContract.query.balanceOf(alice, { gasLimit }alice); 

here is the error:

  RPC-CORE: call(callRequest: ContractCallRequest, at?: BlockHash): ContractExecResult:: createType(ContractExecResult):: Struct: failed on result: {"_enum":{"Ok":"ContractExecResultOk","Err":"ContractExecResultErr"}}:: Enum(Err):: Enum(Module):: Struct: failed on error: u8:: u8: Input too large. Found input with 28 bits, expected 8
  • 1
    try like this: query["psp22::balance_of"]()
    – P.Ossun
    May 3, 2022 at 8:30
  • you also forgot an "," between { gasLimit }, alice
    – P.Ossun
    May 3, 2022 at 9:03
  • You are potentially using the incorrect ABI file for the contract at this address.
    – forgetso
    May 3, 2022 at 15:22
  • 1
    This error message may suggest that the contract does not exist at the address you are providing. Are you sure it is instantiated correctly (promise fulfilled, providing correct account id, etc.)
    – kriko727
    May 3, 2022 at 15:24
  • 1
    Ensure that you are on the latest API version. There has recently been changes made to the error structures in substrate. Since you fail on the result, it would seem to point to that.
    – Xiu Hung
    May 5, 2022 at 6:09

1 Answer 1


There seems to be a mismatch with the adjusted DispatchError enum resulting in a non-decodable result when errors are emitted on calls.

I believe the API only catered for it on the contracts side this week, so the fix should already be available in the the apps UI (the team generally seems to follow the latest API betas there). Judging by normal release cadance (which is generally weekly), the next API version should have the adjustments in.

  • 1
    Indeed. Releases are weekly, generally on weekends (+ or - and day or two)
    – Jaco
    Jun 10, 2022 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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