ethers.js: Error parsing a blank address returned from a contract call

The following contract call:

import {ethers, providers } from 'ethers';

const provider = new providers.JsonRpcProvider("https://mainnet.infura.io/v3/<id>")
// const provider = ethers.providers.getDefaultProvider('mainnet');

var privateKey = '0x00000000000000000000000000000000000000000000000000000000000000d0';
var wallet = new ethers.Wallet(privateKey,provider);

const contract = new ethers.Contract(
  '0xD1E5b0FF1287aA9f9A268759062E4Ab08b9Dacbe',
  [
  {
    constant: true,
    inputs: [
      {
        internalType: 'uint256',
        name: 'tokenId',
        type: 'uint256',
      },
    ],
    name: 'resolverOf',
    outputs: [
      {
        internalType: 'address',
        name: '',
        type: 'address',
      },
    ],
    payable: false,
    stateMutability: 'view',
    type: 'function',
  },

  ],
  wallet,
)

contract.functions.resolverOf(
  '0x2ef86569f09a06f60ae081125c0731d971403c89fb8202f2ca17f1f83f91df1c'
).then(console.log, console.log)

Returns the error:

Error: call revert exception (method="resolverOf(uint256)", errorSignature=null, errorArgs=[null], reason=null, code=CALL_EXCEPTION, version=abi/5.0.1)
    at Logger.makeError (/Users/bogdan/.nvm/versions/node/v14.5.0/lib/node_modules/ethers/node_modules/@ethersproject/logger/lib/index.js:179:21)
    at Logger.throwError (/Users/bogdan/.nvm/versions/node/v14.5.0/lib/node_modules/ethers/node_modules/@ethersproject/logger/lib/index.js:188:20)
    at Interface.decodeFunctionResult (/Users/bogdan/.nvm/versions/node/v14.5.0/lib/node_modules/ethers/node_modules/@ethersproject/abi/lib/interface.js:287:23)
    at Object.<anonymous> (/Users/bogdan/.nvm/versions/node/v14.5.0/lib/node_modules/ethers/node_modules/@ethersproject/contracts/lib/index.js:300:56)
    at step (/Users/bogdan/.nvm/versions/node/v14.5.0/lib/node_modules/ethers/node_modules/@ethersproject/contracts/lib/index.js:46:23)
    at Object.next (/Users/bogdan/.nvm/versions/node/v14.5.0/lib/node_modules/ethers/node_modules/@ethersproject/contracts/lib/index.js:27:53)
    at fulfilled (/Users/bogdan/.nvm/versions/node/v14.5.0/lib/node_modules/ethers/node_modules/@ethersproject/contracts/lib/index.js:18:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  reason: null,
  code: 'CALL_EXCEPTION',
  method: 'resolverOf(uint256)',
  errorSignature: null,
  errorArgs: [ null ],
  address: '0xD1E5b0FF1287aA9f9A268759062E4Ab08b9Dacbe',
  args: [
    '0x2ef86569f09a06f60ae081125c0731d971403c89fb8202f2ca17f1f83f91df1c'
  ],
  transaction: {
    data: '0xb3f9e4cb2ef86569f09a06f60ae081125c0731d971403c89fb8202f2ca17f1f83f91df1c',
    to: '0xD1E5b0FF1287aA9f9A268759062E4Ab08b9Dacbe',
    from: '0x379ff6375F4A44f458683629ef05141d73fAe55A'
  }
}

The returned response from the eth_call RPC is { jsonrpc: '2.0', id: 1, result: '0x' }.

I am not sure how a result like this is generated. It seems like this is a mapping value of mapping (something => address) from non-existent key when returned directly from a function call.

See line 1081 in https://etherscan.io/address/0xD1E5b0FF1287aA9f9A268759062E4Ab08b9Dacbe#code

Should 0x be decoded just like 0x0000000000000000000000000000000000000000 in this case without an error?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

That response is definitely an error with respect to the ABI. The response0x should not be interpreted as any sort of address, not even the zero address.

I’m on my iPhone right now, so just looking at the contract source and can’t run it right now.

I’ll have to look more into the contract later, but I don’t see any implementation for the 'resolverOf` in the source. Maybe it is a proxy that isn’t configured?