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

Call Function "Error: Returned values aren't valid, did it run Out of Gas?" #3650

Closed
safakoks opened this issue Jul 21, 2020 · 3 comments
Closed
Labels
1.x 1.0 related issues Investigate Stale Has not received enough activity

Comments

@safakoks
Copy link

First of all, there are some issues with this error like #3134 and #3466. I could not solve the error by inspecting these issues. And my case is a little bit different.

Here's my contract structure as two different files.

pragma solidity ^0.6.8;

import "./Inheritance.sol";

contract BasicInheritance is Inheritance {
    function add(uint256 _amount) public {
        total += _amount;
        
    }

}
pragma solidity ^0.6.8;

contract Inheritance {
    
    uint public total;
    
    function remove(uint256 _amount) public {
        total -= _amount;   
    }
}

Here's the metadata from the compiled result

{"compiler":{"version":"0.6.11+commit.5ef660b1"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"add","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"remove","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"total","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"BasicInheritance.sol":"Base"},"evmVersion":"istanbul","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"BasicInheritance.sol":{"keccak256":"0x23acb1c662f2aa99f4ae8dff2184a47d20326bdae59ff2bc922b6645815d6f8e","urls":["bzz-raw://bd93d3038120de90ef664532545930a0f92426dbde934b87c4ad75862b263396","dweb:/ipfs/QmctQJZnhfsmqWBd6GkdGo28GiEPDVtLXkhx84U6NNphPf"]},"Inheritance.sol":{"keccak256":"0x3a19b79efdc4eaa6cdadd2418c0784705a493eee78eabd38a0d88731770a113c","urls":["bzz-raw://81bc63c1396ab2a8c4bfb0b5b9928884cf1860c9f9f6afa8b90dbb7cb47a757c","dweb:/ipfs/Qmbsv8amyeJtWvBq6zDjmNXERj5TwEQ7zoW6V6WuGTDxku"]}},"version":1}

If it is needed, here's the bytecode

608060405234801561001057600080fd5b50610113806100206000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c80631003e2d21460415780632ddbd13a14606c5780634cc82215146088575b600080fd5b606a60048036036020811015605557600080fd5b810190808035906020019092919050505060b3565b005b607260c5565b6040518082815260200191505060405180910390f35b60b160048036036020811015609c57600080fd5b810190808035906020019092919050505060cb565b005b80600080828254019250508190555050565b60005481565b8060008082825403925050819055505056fea26469706673582212201408b09e0c5ec7601bb6c6d631c6c67843b390cd75faa88e0017c91f3ecddb3164736f6c634300060b0033

Expected behavior

call function must return the total result.

const currentMethod = web3Contract.methods.total().call({
  from: address,
});

Actual behavior

It returns an error as seen on the log.

As I understand, there are a problem during sending eth_call which returns 0x as result. The same function was worked on remix. And also, conractAddress is exactly correct, other send functions were worked correctly, for example:

const currentMethod = web3Contract.methods.add(123).send({
  from: address,
  gas: 80000000,
}).then(console.log);

Steps to reproduce the behavior

const Web3 = require('web3');

const web3 = new Web3(
  new Web3.providers.WebsocketProvider('ws://35.xxx.xxx.xxx:85xx'),
);

const abi = [{
  inputs: [{ internalType: 'uint256', name: '_amount', type: 'uint256' }], name: 'add', outputs: [], stateMutability: 'nonpayable', type: 'function',
}, {
  inputs: [{ internalType: 'uint256', name: '_amount', type: 'uint256' }], name: 'remove', outputs: [], stateMutability: 'nonpayable', type: 'function',
}, {
  inputs: [], name: 'total', outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], stateMutability: 'view', type: 'function',
}];

const address = '0x378fD9415E9a688139E91ff95C09A571b2AE41Bd';
const privateKey = '0x23c6ae4a8ba382ddd42d29e808fb82dae881db5b3d51803b5b31638a2ebb26cb';
const contractAddress = '0x0D5E83AF211DF7545C059B79C8f654F3d612DAC2';

web3.eth.accounts.wallet.add(privateKey);

const web3Contract = new web3.eth.Contract(
  abi,
  contractAddress,
);

const currentMethod = web3Contract.methods.total().call({
  from: address,
});

currentMethod.then((result) => {
  console.log('result', result);
}).catch((err) => {
  console.error('error', err);
});

Logs

error Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.

Environment

nodejs: v12.16.2
web3: v1.2.11
geth: Geth/v1.8.18-stable(quorum-v2.3.0)/linux-amd64/go1.11.8

@GregTheGreek GregTheGreek added 1.x 1.0 related issues Investigate labels Jul 21, 2020
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

@github-actions github-actions bot added the Stale Has not received enough activity label Aug 21, 2020
@safakoks
Copy link
Author

I found the reason. It occurs because of a no-deployed contract address. Sending raw tx with bytecode returns contract address, so I used the fake contract address which does not refer to a correct deployed contract. I think the error message creates a misunderstanding about the situation.

By the way, It runs correctly on Ganache. But on Quorum it returns the error.

@github-actions github-actions bot removed the Stale Has not received enough activity label Aug 22, 2020
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues Investigate Stale Has not received enough activity
Projects
None yet
Development

No branches or pull requests

2 participants