title: Web3.js returned error: execution reverted
body: <p>I'm new to blockchain programming and web3 and I don't really understand the error.
  I'm trying to call a function from my smart contract (on BSC test net)</p>
  <p>Function is called <code>getRandom</code></p>
  <p>app.js</p>
  <pre class="lang-js prettyprint-override"><code>const Web3 = require(&quot;web3&quot;);
  const web3 = new Web3(&quot;https://speedy-nodes-nyc.moralis.io/redacted/bsc/testnet&quot;);
  const key = &quot;28e........................8&quot;
  const contract = new web3.eth.Contract([
      {
          &quot;inputs&quot;: [],
          &quot;name&quot;: &quot;getRandom&quot;,
          &quot;outputs&quot;: [
              {
                  &quot;internalType&quot;: &quot;uint256&quot;,
                  &quot;name&quot;: &quot;&quot;,
                  &quot;type&quot;: &quot;uint256&quot;
              }
          ],
          &quot;stateMutability&quot;: &quot;nonpayable&quot;,
          &quot;type&quot;: &quot;function&quot;
      }
  ], &quot;0x22191A37B2AB83e7A81758ecd0E120cf080153B1&quot;)
  
  const account = web3.eth.accounts.privateKeyToAccount('0x' + key);
  web3.eth.accounts.wallet.add(account);
  
  (async () =&gt; {
      try {
          const gasPrice = await web3.eth.getGasPrice();
          const gasEstimate = await contract.methods.getRandom().estimateGas({from: account.address});
  
          console.log(contract.methods.getRandom().send({from: account.address, gasPrice: gasPrice, gas: gasEstimate}))
      }
      catch (e) {
          console.log(e)
      }
  })();
  </code></pre>
  <p>Error</p>
  <pre><code>Error: Returned error: execution reverted
      at Object.ErrorResponse (C:\DeFi project\node_modules\web3-core-helpers\lib\errors.js:28:19)
      at C:\DeFi project\node_modules\web3-core-requestmanager\lib\index.js:302:36
      at XMLHttpRequest.request.onreadystatechange (C:\DeFi project\node_modules\web3-providers-http\lib\index.js:98:13)
      at XMLHttpRequestEventTarget.dispatchEvent (C:\DeFi project\node_modules\xhr2-cookies\dist\xml-http-request-event-target.js:34:22)
      at XMLHttpRequest._setReadyState (C:\DeFi project\node_modules\xhr2-cookies\dist\xml-http-request.js:208:14)
      at XMLHttpRequest._onHttpResponseEnd (C:\DeFi project\node_modules\xhr2-cookies\dist\xml-http-request.js:318:14)
      at IncomingMessage.&lt;anonymous&gt; (C:\DeFi project\node_modules\xhr2-cookies\dist\xml-http-request.js:289:61)
      at IncomingMessage.emit (events.js:327:22)
      at endReadableNT (internal/streams/readable.js:1327:12)
      at processTicksAndRejections (internal/process/task_queues.js:80:21) {
    data: null
  }
  </code></pre>
  <p>I'm just trying to get the response from my smart contract's function.</p>