"Gas estimation failed" on Ropsten with Invalid RPC JSON

by d3wannabe   Last Updated August 14, 2019 03:28 AM - source

I'm running into an issue going through a basic example in "Mastering Ethereum"...

I have a Faucet contract (on Ropsten) per the book that looks like...

pragma solidity ^0.5.1; //mastering ethereum uses ^0.4.19;

//our first contract is a faucet!
contract Faucet {

    //give out ether to anyone who asks
    function withdraw(uint withdraw_amount) public {

        //limit withdrawal amount
        require(withdraw_amount <= 100000000000000000);

        //send the amount to the address that requested it


    //accept any incoming amount
    function () payable external {} 

I can deposit funds using MetaMask but when I use Remix to withdraw I see this message...

"Gas estimation failed
Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
gas required exceeds allowance or always failing transaction"

Then if I force Remix to send the transaction anyway, the debugger only gives me:

Debugger: Invalid JSON RPC response: ""

Any ideas how to troubleshoot this further? I have enough ETH in MetaMask to afford the gas so I'm guessing that perhaps the withdraw function I'm using is outdated in some way and needs to return a value?

Related Questions

Smart Contract Working on Remix but not TestNet

Updated March 01, 2019 17:28 PM