title: Error: Returned values aren't valid when trying to call function
body: <p>I created a NameContracts as described here: <a href="https://bitsofco.de/calling-smart-contract-functions-using-web3-js-call-vs-send/" rel="nofollow noreferrer">https://bitsofco.de/calling-smart-contract-functions-using-web3-js-call-vs-send/</a></p>
  
  <p>I compiled &amp; migrated it with truffle and started the ganache-cli. Then I tried to call the function getName with web3, but always get the error:</p>
  
  <pre><code>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.
  </code></pre>
  
  <p>I'm not sure what that means or what I did wrong. I already searched the web, but none of the suggested solutions worked for me. Here's my code:</p>
  
  <pre><code>const Web3 = require('web3');
  const fs = require('fs');
  
  const rpcURL = "http://localhost:8545";
  const web3 = new Web3(rpcURL);
  
  const rawData = fs.readFileSync('NameContract.json');
  const jsonData = JSON.parse(rawData);
  const abi = jsonData["abi"];
  
  let accounts;
  let contract;
  web3.eth.getAccounts().then(result =&gt;{
    accounts = result;
    web3.eth.getBalance(accounts[0], (err, wei) =&gt; {
      balance = web3.utils.fromWei(wei, 'ether')
      console.log("Balance of accounts[0]: " + balance); // works as expected
    })
    contract = new web3.eth.Contract(abi, accounts[0]);
    console.log(contract.methods); // works as expected
    console.log(contract.address); // prints undefined
    contract.methods.getName().call((result) =&gt; {console.log(result)}); // throws error
  })
  </code></pre>