title: How do you estimate the current gas limit before sending a transaction?
body: <p>Specifically, I want my node.js to be able to send an ERC721 token to another wallet. Sometimes, the gas price is high and my transaction gets stuck there for hours. In these cases, I would like my node.js to use more gas to send the token on time.</p>
  <p>I've tried getting the last block's gas limit, but it always seems to be far too low.</p>
  <pre><code>  var count = web3.eth.getTransactionCount(sender);
  
    var rawTransaction;
  
    var block = web3.eth.getBlock(&quot;latest&quot;);
    var currGas = block.gasLimit;
    currGas = currGas.toString(16);
    currGas = '0x' + currGas;
  
    if(isSending){
      rawTransaction = {
          &quot;from&quot;: sender,
          &quot;nonce&quot;: web3.toHex(count),
          &quot;gasPrice&quot;: currGas,
          &quot;gasLimit&quot;: &quot;0x3A980&quot;,
          &quot;to&quot;: skyDropContract,
          &quot;value&quot;: &quot;0x0&quot;,          
          &quot;data&quot;: myContractABI.startGame.getData(index, {from: sender}),
          &quot;chainId&quot;: 0x01
      };
    }
  </code></pre>
  <p>I am using <code>web3@0.20.0</code> but can switch versions if I really need to. Is there a way to estimate the cost of my transaction before sending it? I might even go 1 gWei over the current estimated cost.</p>