Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbiError: Parameter decoding error: decoded value is less then minimum for given type #7046

Open
0xankit opened this issue May 17, 2024 · 1 comment
Labels
4.x 4.0 related Bug Addressing a bug

Comments

@0xankit
Copy link

0xankit commented May 17, 2024

Expected behavior

for the following code:

pragma solidity ^0.8.0;
    mapping(bytes32 => CredentialSchema) private schemas; // mapping to store schema ID to schema details mapping

function getSchema(bytes32 _guid) public view returns (CredentialSchema memory) {
        require(isSchemaIdExists(_guid) == true, "Schema with this GUID does not exist");
        return schemas[_guid];
    }
// Function to check if a schema ID already exists
    function isSchemaIdExists(bytes32 _guid) private view returns (bool) {
        return schemas[_guid].guid != bytes32(0);
    }

When any existing guid is being passed it returns the correct schema. Following are the tests for above function which works fine while testing through hardhat. i.e It is reverting with the correct message.

it("Should prevent fetching non-existent schema", async function () {
    await expect(
      schemaRegistry.getSchema(schema.guid.replace("a", "b").replace("c", "d"))
    ).to.be.revertedWith("Schema with this GUID does not exist");
  });

Actual behavior

But when being called from web3js it throws AbiError: Parameter decoding error: decoded value is less then minimum for given type

async function getSchemaByGuid(guid) {
  try {
    console.debug("Getting schema by guid: ", guid);
    const result = await schemaRegistryContract.methods.getSchema(guid).call();
    return result;
  } catch (error) {
    throw error;
  }
}

Logs

following is the error log:

AbiError: Parameter decoding error: decoded value is less then minimum for given type
    at decodeParametersWith (.../node_modules/web3-eth-abi/lib/commonjs/api/parameters_api.js:103:15)
    at decodeParameters (.../node_modules/web3-eth-abi/lib/commonjs/api/parameters_api.js:213:75)
    at decodeMethodReturn (.../node_modules/web3-eth-contract/lib/commonjs/encoding.js:136:56)
    at ContractBuilder.<anonymous> (.../node_modules/web3-eth-contract/lib/commonjs/contract.js:773:61)
    at Generator.next (<anonymous>)
    at fulfilled (.../node_modules/web3-eth-contract/lib/commonjs/contract.js:21:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  innerError: undefined,
  code: 205,
  props: {
    internalErr: AbiError: decoded value is less then minimum for given type
        at decodeNumber (.../node_modules/web3-eth-abi/lib/commonjs/coders/base/number.js:94:15)
        at decodeTuple (.../node_modules/web3-eth-abi/lib/commonjs/coders/base/tuple.js:99:63)
        at decodeParameters (.../node_modules/web3-eth-abi/lib/commonjs/coders/decode.js:26:39)
        at decodeParametersWith (.../node_modules/web3-eth-abi/lib/commonjs/api/parameters_api.js:100:49)
        at decodeParameters (.../node_modules/web3-eth-abi/lib/commonjs/api/parameters_api.js:213:75)
        at decodeMethodReturn (.../node_modules/web3-eth-contract/lib/commonjs/encoding.js:136:56)
        at ContractBuilder.<anonymous> (.../node_modules/web3-eth-contract/lib/commonjs/contract.js:773:61)
        at Generator.next (<anonymous>)
        at fulfilled (.../node_modules/web3-eth-contract/lib/commonjs/contract.js:21:58)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
      innerError: undefined,
      code: 205,
      props: [Object]
    }
  }
}

Environment

 "web3": "^4.8.0"
 
# hardhat env
"devDependencies": {
    "@nomicfoundation/hardhat-toolbox": "^5.0.0",
    "hardhat": "^2.22.3"
  }
  
 ❯ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.4 LTS
Release:        22.04
Codename:       jammy

 ❯ node --version
v21.5.0
@mconnelly8 mconnelly8 added 4.x 4.0 related Bug Addressing a bug labels May 17, 2024
@mconnelly8
Copy link

Thanks for the details @0xankit. We will take a look at this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x 4.0 related Bug Addressing a bug
Projects
None yet
Development

No branches or pull requests

2 participants