0

I'm trying to get all Transfer events from an account of an ERC721 token, I'm currently struggling with the following error. I googled around but couldn't find much helpful things. I'm definitely on the right network (mainnet) and the contracts are deployed and functional as far as I can tell.

getWeb3.js: https://gist.github.com/adrianmcli/2f42dd98f7d900ec7828930a4a7a1e97

transactions.js

  import getWeb3 from "../utils/getWeb3";
  import { MintableNonFungibleToken } from "non-fungible-token-abi";
  import Utils from "web3-utils";
  const web3 = yield getWeb3();

  var myContract = new web3.eth.Contract(
    MintableNonFungibleToken,
    "0x8c9b261faef3b3c2e64ab5e58e04615f8c788099"
  );
  const addr = "0x0a8e20ee171630ef9dfebf02149169f90c133cd8";
  const events = yield myContract.getPastEvents("Transfer", {
    fromBlock: 0,
    toBlock: "latest",
    topics: [
      Utils.sha3("Transfer(address,address,uint256)"),
      Utils.padLeft(addr, 64)
    ]
  });
  console.log(events);

Error

 Error: Couldn't decode uint256 from ABI: 0x
    at SolidityTypeUInt.formatOutputUInt [as _outputFormatter] (http://localhost:3000/bundle.js:48786:15)
    at SolidityTypeUInt.../../node_modules/web3-eth-abi/src/type.js.SolidityType.decode (http://localhost:3000/bundle.js:49746:17)
    at http://localhost:3000/bundle.js:49238:49
    at Array.forEach (<anonymous>)
    at ABICoder.../../node_modules/web3-eth-abi/src/index.js.ABICoder.decodeParameters (http://localhost:3000/bundle.js:49237:13)
    at ABICoder.../../node_modules/web3-eth-abi/src/index.js.ABICoder.decodeLog (http://localhost:3000/bundle.js:49281:33)
    at Object.../../node_modules/web3-eth-contract/src/index.js.Contract._decodeEventABI (http://localhost:3000/bundle.js:55150:31)
    at http://localhost:3000/bundle.js:38813:57
    at Array.map (<anonymous>)
    at Method.../../node_modules/web3-core-method/src/index.js.Method.formatOutput (http://localhost:3000/bundle.js:38812:23)

I checked and I'm getting data from the actual RPC call but it seems web3 cannot process the answer from RPC.

  • Could you provide ABI of your contract? – Aquila Oct 15 '18 at 15:37
1

There are multiple issues can lead to the error based on the long thread https://github.com/ethereum/web3.js/issues/1089

First of all you need to be sure, that your code and ABI synchronized. I mean even small changes in function signatures without updating ABI can lead to the issue.

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.