Web3.js: getPastEvents failing to decode empty data

Created on 4 Sep 2018  路  64Comments  路  Source: ChainSafe/web3.js

I'm trying out web3 v1.0.0-beta.36 and having some trouble with pulling events from a contract.

The events do not return any data, and getPastEvents is throwing this error:

Error: Returned values aren't valid, did it run Out of Gas?

The same action works in web3 0.20.7 no problem.

Is it possible a bug in decoding of empty event data 0x may have slipped through the cracks?

bug

Most helpful comment

Thanks for submitting this issue I will fix that in the next build.

All 64 comments

Probably same issue here.

Error: Returned values aren't valid, did it run Out of Gas?

TestCode:

contract = new web3.eth.Contract(abi,address);    

contract.events.TestEvent(()=>{
}).on('data', function(event){
 console.log(event);
}).on('error', function(error){
 console.log(error);
});

Did work in beta.35 throws error in beta.26 althougt not in the error handler.

Same problem on web3 beta.35 and beta.36

I'm running into the same issue with 1.0.0-beta.36 and MetaMask provider.

Edit: Error occurs in web3-eth-abi index.js:226. The bytes parameter has a value of 0x and outputs === [].

As a workaround I uncommented that error throwing line. I can't see any negative side effects so far. The event is accessable and my DAPP works as intended. It's just that weirdo in between.

Here's an example transaction causing web3 to break: https://rinkeby.etherscan.io/tx/0x2f943ce121c47624fc00b7829bf5d8cae26c1fe97365c250063d7da6d9a1f6df

The according solidity event:
event Release(uint256 indexed id, address indexed owner);
Provisioned values: (8, msg.sender)

Probably same issue here.

Error: Returned values aren't valid, did it run Out of Gas?

TestCode:

contract = new web3.eth.Contract(abi,address);    

contract.events.TestEvent(()=>{
}).on('data', function(event){
 console.log(event);
}).on('error', function(error){
 console.log(error);
});

Did work in beta.35 throws error in beta.26 althougt not in the error handler.

have u solved it yet? I have met the same problem

The comment previous to yours mentions how to fix it.

Got the same issue.
the version of web3: 1.0.0-beta.33;
the detail code:

const Web3 = require("web3");

let web3 = new Web3(
  new Web3.providers.WebsocketProvider("wss://rinkeby.infura.io/ws")
);

const ABI = [...];
const addrC = '0x...';
const testC = new web3.eth.Contract(ABI,addrC);

testC.getPastEvents("Log", { fromBlock: 0, toBlock: "latest" }, function(
  error,
  events
) {
  if (error) {
    console.log(error);
  } else {
    console.log(events);
  }
});

the output:

Error: Returned values aren't valid, did it run Out of Gas?
    at ABICoder.decodeParameters (C:\Users\userName\Desktop\web3-1\node_modules\web3-eth-abi\src\index.js:226:15)
    at ABICoder.decodeLog (C:\Users\userName\Desktop\web3-1\node_modules\web3-eth-abi\src\index.js:283:52)
    at Object.Contract._decodeEventABI (C:\Users\userName\Desktop\web3-1\node_modules\web3-eth-contract\src\index.js:377:31)
    at C:\Users\userName\Desktop\web3-1\node_modules\web3-core-method\src\index.js:160:57
    at Array.map (<anonymous>)
    at Method.formatOutput (C:\Users\userName\Desktop\web3-1\node_modules\web3-core-method\src\index.js:159:23)
    at sendTxCallback (C:\Users\userName\Desktop\web3-1\node_modules\web3-core-method\src\index.js:473:33)
    at Object.<anonymous> (C:\Users\userName\Desktop\web3-1\node_modules\web3-core-requestmanager\src\index.js:147:9)
    at C:\Users\userName\Desktop\web3-1\node_modules\web3-providers-ws\src\index.js:121:44
    at Array.forEach (<anonymous>)
    at W3CWebSocket.WebsocketProvider.connection.onmessage (C:\Users\userName\Desktop\web3-1\node_modules\web3-providers-ws\src\index.js:98:36)
    at W3CWebSocket._dispatchEvent [as dispatchEvent] (C:\Users\userName\Desktop\web3-1\node_modules\yaeti\lib\EventTarget.js:107:17)
    at W3CWebSocket.onMessage (C:\Users\userName\Desktop\web3-1\node_modules\websocket\lib\W3CWebSocket.js:234:14)
    at WebSocketConnection.<anonymous> (C:\Users\userName\Desktop\web3-1\node_modules\websocket\lib\W3CWebSocket.js:205:19)
    at WebSocketConnection.emit (events.js:182:13)
    at WebSocketConnection.processFrame (C:\Users\userName\Desktop\web3-1\node_modules\websocket\lib\WebSocketConnection.js:552:26)
    at C:\Users\userName\Desktop\web3-1\node_modules\websocket\lib\WebSocketConnection.js:321:40
    at process._tickCallback (internal/process/next_tick.js:61:11)

Same problem on beta.36

It looks like given error:

Error: Returned values aren't valid, did it run Out of Gas?

only occures when event definition which You want to read/download using getPastEvents method has every parameter field marked as indexed.

Transfer event definition from ERC-721:

  event Transfer(
    address indexed _from,
    address indexed _to,
    uint256 indexed _tokenId
  );

Use getPastEvents to read Transfer events will fail due to such error. This also means that You custom events build in Your contracts will also fails.

I tested events with mixed fields (2 x indexed, 2 x not indexed) and it works fine for me.
Seems like we have to wait for patch or propose one.

This seems to be an issue many are hitting including myself. Just attempting to go back through the versions to try and see where this may have started.

Can confirm this was introduced in v1.0.0-beta.36 in my case, specifying v1.0.0-beta.35 exactly and re-running brings up events as expected rather than the "Error: Returned values aren't valid, did it run Out of Gas?".

[email protected] works fine

Same issue. Downgrading to beta 35 worked for as well.

Thanks for submitting this issue I will fix that in the next build.

The issue isn't specific to handling empty data, it fails for me when data is supposed to be returned as well. Just to make that clear :)

same issue

I get the same issue using web3.eth.ens.getMultihash on the version 36 and 35. Any advice? I can confirm that there would be nothing returned (as previously 'web3.eth.ens.setMultihash' was never set on this ENS address. Thanks.

Added simple project that demonstrates this issue. It happens also when the event has only indexed values - hence no data.

https://github.com/yarrumretep/web3_1916

My fix:

patch-package
--- a/node_modules/web3-eth-abi/src/index.js
+++ b/node_modules/web3-eth-abi/src/index.js
@@ -280,7 +280,7 @@ ABICoder.prototype.decodeLog = function (inputs, data, topics) {


     var nonIndexedData = data;
-    var notIndexedParams = (nonIndexedData) ? this.decodeParameters(notIndexedInputs, nonIndexedData) : [];
+    var notIndexedParams = (nonIndexedData && nonIndexedData !== '0x') ? this.decodeParameters(notIndexedInputs, nonIndexedData) : [];

     var returnValue = new Result();
     returnValue.__length__ = 0;

Any ETA for the next build?

I got the same error. The weird things is all worked fine, untill suddenly it gave me that error.
Downgrading to 1.0.0-beta.35 gives me this error:
Couldn't decode uint256 from ABI: 0x

@yarrumretep how do we implement your fix?
I changed the proposed data in the index.js file.
The errror is still there.

Update:
I think this error has to do with MetaMask. I was running some tests and it turns out I don't have the error when I run my browser in private mode. Then when I removed MetaMask, all worked fine again.
Hope this helps @nivida .

1.0.0-beta.35 also solves it for me. Fix this.

1.0.0-beta.35 also solves it for me. Fix this.

Bump

Had the same error with version 1.0.
But, in my case I'm not dealing with events... but, calling a getter method that would return an int value which is zero ('0').

Error: Returned values aren't valid, did it run Out of Gas?

Rinkeby testnet:

        web3 = new Web3(web3.currentProvider);
        var address = "0xc6482382047fb50e8e7b4658425c9756b28f995c";
        var abi = [
                    ...
                    ];
        contract = new web3.eth.Contract(abi, address);
        contract.methods.getCounter().call().then((result) => {
            console.log(result);
        }).catch(function(err){
            console.log('err...\n'+err);
        });

Switched to version _web3.js 1.0.0-beta.35_.
But, this time the error is different:

Error: Couldn't decode from ABI: 0x.

Any idea?

I had error "Error: Couldn't decode from ABI: 0x." when call get request with wrong contract address

@Veniamin _Thank You!_

You made my day :-)

I was using 'account address', instead of 'contract address' :-P

1.0.0-beta.35 also solves it for me. Fix this.

Experiencing this with 1.0.0-beta.36 when reading Zepplin's new Transfer event which now has all parameters set to indexed.

Using 1.0.0-beta36, having this issue, this fix works.

I'm using 1.0.0-beta36 and similar error occured.
But in my case this fix didn't work.

summary

  1. build solidity that imports open-zeppelin by truffle.
  2. the built files have the abi whose outputs defines name is empty.
  3. when doing contract.methods.[function].call() from web app, formatOutput in Method.prototype.buildCall will fail.

This error seems because the name of abi outputs is empty.

abi and call

const abi =   [{
      "constant": true,
      "inputs": [],
      "name": "totalSupply",
      "outputs": [
        {
          "name": "",
          "type": "uint256"
        }
      ],
      "payable": false,
      "stateMutability": "view",
      "type": "function"
    }];

this.contract = await new this.web3.eth.Contract(abi, contractAddress);
this.contract.methods.totalSupply().call();

stacktrace

ERROR Error: Uncaught (in promise): Error: Returned values aren't valid, did it run Out of Gas?
Error: Returned values aren't valid, did it run Out of Gas?
    at ABICoder.push../node_modules/web3-eth-abi/src/index.js.ABICoder.decodeParameters (index.js:226)
    at Contract.push../node_modules/web3-eth-contract/src/index.js.Contract._decodeMethodReturn (index.js:465)
    at Method.outputFormatter (index.js:818)
    at Method.push../node_modules/web3-core-method/src/index.js.Method.formatOutput (index.js:163)
    at sendTxCallback (index.js:473)
    at index.js:147
    at inpage.js:1
    at inpage.js:1
    at i (inpage.js:1)
    at inpage.js:1
    at ABICoder.push../node_modules/web3-eth-abi/src/index.js.ABICoder.decodeParameters (index.js:226)
    at Contract.push../node_modules/web3-eth-contract/src/index.js.Contract._decodeMethodReturn (index.js:465)
    at Method.outputFormatter (index.js:818)
    at Method.push../node_modules/web3-core-method/src/index.js.Method.formatOutput (index.js:163)
    at sendTxCallback (index.js:473)

Running into the same issue as @studioTeaTwo -- any tips on how to resolve it? Also getting it from a .call(), was able to successfully complete a regular .send().

EDIT: Downgrading to beta.35 gave me Error: Couldn't decode from ABI: 0x. as well, but I'm certain that my provided address is the correct one.

I can confirm that querying ERC-721 events with all indexed parameters works if you rollback beta 36 to beta 35. @exogenesick I think that is what you are doing.

npm install [email protected]

Today is one of those days I sat down thinking "now is a fun time to run npm update, nothing is broken but hey what could go wrong?"

@yarrumretep, proper check in your fix must be (notIndexedInputs.length != 0 && nonIndexedData)

While we wait for a fix, here's another hack that seems to do the trick:

web3.eth.abi.decodeParameters = function(outputs, bytes) {
  if (bytes === '0x') bytes = '0x00'
  return web3.eth.abi.__proto__.decodeParameters(outputs, bytes)
}

Added simple project that demonstrates this issue. It happens also when the event has only indexed values - hence no data.

https://github.com/yarrumretep/web3_1916

My fix:

patch-package
--- a/node_modules/web3-eth-abi/src/index.js
+++ b/node_modules/web3-eth-abi/src/index.js
@@ -280,7 +280,7 @@ ABICoder.prototype.decodeLog = function (inputs, data, topics) {


     var nonIndexedData = data;
-    var notIndexedParams = (nonIndexedData) ? this.decodeParameters(notIndexedInputs, nonIndexedData) : [];
+    var notIndexedParams = (nonIndexedData && nonIndexedData !== '0x') ? this.decodeParameters(notIndexedInputs, nonIndexedData) : [];

     var returnValue = new Result();
     returnValue.__length__ = 0;

I deploy it with heroku. How to edit on it?

Added simple project that demonstrates this issue. It happens also when the event has only indexed values - hence no data.
https://github.com/yarrumretep/web3_1916
My fix:

patch-package
--- a/node_modules/web3-eth-abi/src/index.js
+++ b/node_modules/web3-eth-abi/src/index.js
@@ -280,7 +280,7 @@ ABICoder.prototype.decodeLog = function (inputs, data, topics) {


     var nonIndexedData = data;
-    var notIndexedParams = (nonIndexedData) ? this.decodeParameters(notIndexedInputs, nonIndexedData) : [];
+    var notIndexedParams = (nonIndexedData && nonIndexedData !== '0x') ? this.decodeParameters(notIndexedInputs, nonIndexedData) : [];

     var returnValue = new Result();
     returnValue.__length__ = 0;

I deploy it with heroku. How to edit on it?

Downgrade to 1.0.0-beta33, that fixes too.

I was trying to watch for an event that had 2 params as indexed and one as non indexed, and I was getting the same error.
Downgrading to beta 35 just changed the error message to Error: Couldn't decode from ABI: 0x.
I finally downgraded to beta 33 and that has fixed the problem.

Error stil happen with web3^1.0.0-beta.37

I have the same problem when I moved my truffle tests from Truffle 4 to Truffle 5 (web3 v10.0.0 beta37). It seems that events emitted by inherited contracts (like OpenZeppelin's ERC20 [email protected]) generate this error (even when modified to be non-indexed).
An event emitted by my own contract which is calling OZ's ERC20 transferFrom does not cause this error.
I can't tell though if this is a web3 or truffle-contract issue in my case.

Same problem here with version 1.0.0-beta.37 attempting to invoke the call method of a smart contract method.

What should we do?

@marf From my own experience events in web3.js's 1.0.0-beta releases are broken. You have to create workaround using different web3 library e.g. ethers.

I had the same issue but a different workflow. As some others mentioned too, it happens for me when using OZ's new ERC-721 contracts in which they've indexed every parameter of the event Transfer.

My workaround: I removed the indexed from one of the parameters and it fixed the issue. I'll wait for a true solution.

I'm using 1.0.0-beta.33 too, so downgrading isn't an option. Also, note the same code worked without errors and randomly starting happening. Somebody mentioned something similar earlier in this thread too.

For anyone who comes across this:
The web3 versions are not broken, but follow the new ABI version 2, which requires that 0x be reserved for error conditions, and as such web3 throws when such response is received from the network.
ABI v2 added (#1820) (https://github.com/ethereum/web3.js/commit/0ef6ee8e9905ad6635747c02cbefd8074350068b#diff-0f39f52256cec08b5ed7384cbbe93719R225)

You need to ensure that your flow or implementation accounts for this, else you would keep having the issue starting from web3 v1.0.0-beta.36

For anyone who comes across this:
The web3 versions are not broken, but follow the new ABI version 2, which requires that 0x be reserved for error conditions, and as such web3 throws when such response is received from the network.
ABI v2 added (#1820) (0ef6ee8#diff-0f39f52256cec08b5ed7384cbbe93719R225)

You need to ensure that your flow or implementation accounts for this, else you would keep having the issue starting from web3 v1.0.0-beta.36

Thanks for your information, could you give more detail? How to ensure my flow accounts for this?

@mavericklin The onus s mainly on the nodes or node providers, to ensure that when 0x is returned as the data, it is an indication of an error and not null/empty data.
This would also ensure a standard across all the nodes for expected data for abi encoding and decoding, and in essence for advanced data types handling.
So, you would basically want to be on the most recent version of the nodes, which should most likely conform with the standard.

Fixed it in the PR #2000 and you should be able to test it with this git tag: https://github.com/ethereum/web3.js/tree/v1.0.0-beta.38-rc2

Module not found: Can't resolve 'eth-lib/src/hash' :confused:

Throws the same error when inside a transaction it generates different events with the same name and the same arguments. In my case, this was the Transfer event from ERC721 and ERC20. Renaming one of them solves this problem, but of course this isn't the right way.

This should get fixed with the next release. I had a issue with the getPastEvents method but it got fixed today with the PR #2338.

Downgrading to beta 33 bring me more trouble than solution

For the first campaign in the same address, I was able to get the requests and manipulate on the same, however, while I created another campaign this error started to pop up whenever I try to click on the get request button.
"dependencies": {
"fs-extra": "^7.0.1",
"ganache-cli": "^6.3.0",
"mocha": "^5.2.0",
"next": "^4.1.4",
"next-routes": "^1.4.2",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"semantic-ui-css": "^2.4.1",
"semantic-ui-react": "^0.85.0",
"solc": "^0.4.25",
"truffle-hdwallet-provider": "0.0.3",
"web3": "^1.0.0-beta.37"

@DiePlease This means this error still occurs in the latest version? It shouldn't because I've tested it and it worked. 馃

@DiePlease This means this error still occurs in the latest version? It shouldn't because I've tested it and it worked. thinking

I confirm, faced that issue with beta 46, nothing helped so far and I had to deprecate the events causing this.

@nivida I am still facing the same issue

The 4th comment (6 months ago) for this issue mentions how to fix it, comment out one line. I made this change months ago and have not had an issue since. So not sure why this issue still remains unresolved.

New version is using Promises,
I was getting the same error and then following code work for me.
z4contract.methods.name().call() .then((result) => { console.log(result); });

promises don't work quite the same in a for loop as await/async. This bug is so annoying though.

facing the same issue in [email protected]. However, code works fine without any problems? Can I ignore this error?


Uncaught (in promise) Error: Returned values aren't valid, did it run Out of Gas?
    at ABICoder.../../../.nvm/versions/node/v8.15.1/lib/node_modules/embark/node_modules/web3-eth-abi/src/index.js.ABICoder.decodeParameters (index.js:226)
    at Contract.../../../.nvm/versions/node/v8.15.1/lib/node_modules/embark/node_modules/web3-eth-contract/src/index.js.Contract._decodeMethodReturn (index.js:465)
    at Method.outputFormatter (index.js:818)
    at Method.../../../.nvm/versions/node/v8.15.1/lib/node_modules/embark/node_modules/web3-core-method/src/index.js.Method.formatOutput (index.js:163)
    at sendTxCallback (index.js:473)
    at Object.<anonymous> (index.js:147)
    at index.js:121
    at Array.forEach (<anonymous>)
    at WebSocket.WebsocketProvider.connection.onmessage (index.js:98)

also seeing this bug in [email protected]

Same issue executing "contract.methods.name().call() .then((result) => { console.log(result); });"

I noticed in this method
in web3-eth-abi

before in a method bytes is "0x" then
if (response.length >= 2) {
response = response.slice(2);
}
so bytes now is = "" then is sending to:
.....
key: "decodeParameters",
value: function decodeParameters(outputs, bytes) {
if (outputs.length > 0 && (!bytes || bytes === '0x' || bytes === '0X')) {
throw new Error("Returned values aren't valid, did it run Out of Gas?");
}
....

bytes = "" so always return "Returned values aren't valid, did it run Out of Gas?"

I'm having the same error when doing truffle migrate. But ONLY when using Ganache GUI, not when using Ganache CLI. Does this imply the problem is not in fact with web3?

I tried downgrading web2 to 35 (from 37) like others suggested but it didn't make a difference.

This got fixed with the PR https://github.com/ethereum/web3.js/pull/2608 and will be released asap.

Same error on web3:1.0.0-beta.37 - Resolved by downgrading the solc from 0.5.9 to 0.5.3.

Same error on Web3.js v1.0.0-beta.37

@wangjunbao2018

Same error on Web3.js v1.0.0-beta.37

Resolved by downgrading the solc compiler version to 0.5.1+commit.c8a2cb62

Same error when call methods.mymethods().call():
web3 version: 1.2.1
Error msg: Error: Returned values aren't valid, did it run Out of Gas?

But it works by downgrading the solc compiler version to 0.5.1+commit.c8a2cb62
Thanks to @kunaltawatia

I'm experiencing the same problem by running:

contract.methods.balanceOf('0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1').call()

directly in truffle console where contract = new web3.eth.Contract(JSON.parse(abi), '0x6b175474e89094c44da98b954eedeac495271d0f') (DAI)

Truffle v5.1.13 (core: 5.1.13)
Solidity - 0.5.1 (solc-js)
Node v10.14.1
Web3.js v1.2.1

Using a Geth node (Ethereum Grid) and ganache-cli --fork http://localhost:8545

That simple call() above returns:

Error: Returned values aren't valid, did it run Out of Gas?

@0xEther There might be a problem with the ABI you're passing in.

Just tried this call using Web3 1.2.6 and the ABI published to etherscan, here.

  const web3 = new Web3('https://mainnet.infura.io/v3/<INFURA_ID>');
  const abi = [{"inputs":[{"internalType":"uint256","name":"chainId_","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"src","type":"address"},{"indexed":true,"internalType":"address","name":"guy","type":"address"},{"indexed":false,"internalType":"uint256","name":"wad","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":true,"inputs":[{"indexed":true,"internalType":"bytes4","name":"sig","type":"bytes4"},{"indexed":true,"internalType":"address","name":"usr","type":"address"},{"indexed":true,"internalType":"bytes32","name":"arg1","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"arg2","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"LogNote","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"src","type":"address"},{"indexed":true,"internalType":"address","name":"dst","type":"address"},{"indexed":false,"internalType":"uint256","name":"wad","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":true,"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"guy","type":"address"}],"name":"deny","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"mint","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"move","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"holder","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"bool","name":"allowed","type":"bool"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"pull","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"push","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"guy","type":"address"}],"name":"rely","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"wards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}];
  const contract = new web3.eth.Contract(abi, '0x6b175474e89094c44da98b954eedeac495271d0f');
  const balance = await contract.methods.balanceOf('0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1').call();
  console.log('balanceOf --> ' + balance);

..outputs

balanceOf --> 0

Same error when using solidity version ^0.6.0;
I noticed that some of solc 0.6.x breaking changes involves ABI: "ABI: Remove the deprecated constant and payable fields." and "The type field is now required and no longer specified to default to function."

I did a dump of my ABI from upgrade to 0.6.x (below) and similar dump from 0.5.x: Constant is deprecated maybe that's the problem (?)

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"Update","type":"uint256"}],"name":"NewData","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldRelayHub","type":"address"},{"indexed":true,"internalType":"address","name":"newRelayHub","type":"address"}],"name":"RelayHubChanged","type":"event"},{"inputs":[],"name":"getHubAddr","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"context","type":"bytes"},{"internalType":"bool","name":"success","type":"bool"},{"internalType":"uint256","name":"actualCharge","type":"uint256"},{"internalType":"bytes32","name":"preRetVal","type":"bytes32"}],"name":"postRelayedCall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"context","type":"bytes"}],"name":"preRelayedCall","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"relayHubVersion","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"num","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"get","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"relay","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"bytes","name":"encodedFunction","type":"bytes"},{"internalType":"uint256","name":"transactionFee","type":"uint256"},{"internalType":"uint256","name":"gasPrice","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes","name":"approvalData","type":"bytes"},{"internalType":"uint256","name":"maxPossibleCharge","type":"uint256"}],"name":"acceptRelayedCall","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"}]
Was this page helpful?
0 / 5 - 0 ratings