1

I am trying to obtain the value of a state variable in my smart contract declared simply as string public projectName; at the top of my smart contract, which is deployed to the Polygon Mumbai testnet.

The error message produced when I attempt to get the value of projectName using await myContract.projectName() is a mile long but begins with this:

`ERROR Error: Uncaught (in promise): Error: missing revert data in call exception; Transaction reverted without a reason string [ See: https://links.ethers.org/v5-errors-

CALL_EXCEPTION ] (error={"reason":"processing response error","code":"SERVER_ERROR","body":"{"jsonrpc":"2.0","id":44,"error":{"code":-32000,"message":"execution reverted"}}","error":{"code":-32000},"requestBody":"{"method":"eth_call","params":[{"gas":"0x1badb18","to":"0x9f5638061917fe4b170d872ef96a18b2c0d4360b","data":"0x261a323e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001373696d706c6562696e64696e672e312e302e3000000000000000000000000000"},"latest"],"id":44,"jsonrpc":"2.0"}","requestMethod":"POST","url":"https://polygon-mumbai.g.alchemy.com/v2/cQFNnUmK-mvQ7H61x7-PEaEhRxUg7JVd"}, data="0x", code=CALL_EXCEPTION, version=providers/5.6.4) Error: missing revert data in call exception; Transaction reverted without a reason string [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (error={"reason":"processing response error","code":"SERVER_ERROR","body":"{"jsonrpc":"2.0","id":44,"error":{"code":-32000,"message":"execution reverted"}}","error":{"code":-32000},"requestBody":"{"method":"eth_call","params":[{"gas":"0x1badb18","to":"0x9f5638061917fe4b170d872ef96a18b2c0d4360b","data":"0x261a323e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001373696d706c6562696e64696e672e312e302e3000000000000000000000000000"},"latest"],"id":44,"jsonrpc":"2.0"}","requestMethod":"POST","url":"https://polygon-mumbai.g.alchemy.com/v2/cQFNnUmK-mvQ7H61x7-PEaEhRxUg7JVd"}, data="0x", code=CALL_EXCEPTION, version=providers/5.6.4) at Logger.makeError (index.js:219:1) at Logger.throwError (index.js:228:1) at checkError (json-rpc-provider.js:59:1) at AlchemyProvider. (json-rpc-provider.js:518:1) at Generator.throw () at rejected (json-rpc-provider.js:6:42) at _ZoneDelegate.invoke (zone.js:372:1) at Object.onInvoke (core.mjs:25587:1) at _ZoneDelegate.invoke (zone.js:371:1) at Zone.run (zone.js:134:1) at resolvePromise (zone.js:1211:1) at zone.js:1118:1 at asyncGeneratorStep (asyncToGenerator.js:6:1) at _throw (asyncToGenerator.js:29:1) at _ZoneDelegate.invoke (zone.js:372:1) at Object.onInvoke (core.mjs:25587:1) at _ZoneDelegate.invoke (zone.js:371:1) at Zone.run (zone.js:134:1) at zone.js:1275:1 ...

The fact that I am relying on the "free accessor function" that comes when you declare a state variable public makes me think that the problem is not in the contract, but rather in the way I am attempting to call it in my front end (Angular) application.

The code for obtaining and calling the function is as follows:

public async getBindingCollectionName(collectionAddress : string) : Promise<string> {
  let collection = await this.getBKBindingCollection(collectionAddress) as BKBindingCollection;
  let projectName = await collection.projectName();    <- fails here;
  return projectName;
}

I get the reference to the contract itself with this function:

private  async fetchChainBindingCollection(address : string) : Promise<BKBindingCollection> {
  let abi = bindingCollectionJson.abi;
  let bc : BKBindingCollection;
  bc = new ethers.Contract(address, abi, this.alchemyProvider) as BKBindingCollection;
 return bc;

}

The json file comes from the artifacts folder of my hardhat project in which this contract was originally deployed to the Polygon Mumbai testnet. The BKBindingCollection class is coming from the BKBindingCollection.d.ts defined in the typechain folder in my hardhat project. PolygonScan shows a contract present at the address I am using in the function above, and some functions appear to work, so it seems like the Alchemy provider is connecting. All of this works fine inside my hardhat project, but not so much in the angular front end. I was able to call a setProjectName function immediately after the deply on hardhat, but trying to access this contract in my front end app (Angular) using ethers.js (no hardhat in the frontend) has been quite difficult.

Suggestions appreciated.

1 Answer 1

3

In case anyone comes across this trying to hunt down a reason for "missing revert data in call exception" in this case it was the result of calling a function that existed in the ABI I was using, but not in the actual contract deployed on the Blockchain. In other words, I supplied the wrong contract address when I created the contract using new ethers.Contract(address, abi, signer)

1
  • Thanks, I was connected to the completely wrong Contract.
    – gneric
    Commented Jun 17, 2022 at 7:25

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.