Wallets cannot estimate the gas required for my contract call

I’ve deployed a contract on Rinkeby here:
https://rinkeby.etherscan.io/address/0x117547f447780df51c6835c1d4d4ddd18b47e5d0#code

Essentially, I’m expecting any wallet to estimate the gas required for the fallback function when I send ETH, but instead they try to use 21,000 and the execution runs out of gas. I think it requires somewhere up around the 70,000 mark. Why would this happen, and is there a way to change my contract such that it has the same functionality, but is able to have its fallback function gas cost estimated?

Code is verified on Rinkeby (added below for convenience)

/**
 *Submitted for verification at Etherscan.io on 2019-08-01
*/

pragma solidity 0.5.10;

contract AbstractAccount {

  event DeviceAdded(address device, bool isOwner);
  event DeviceRemoved(address device);
  event TransactionExecuted(address recipient, uint256 value, bytes data, bytes response);

  struct Device {
    bool isOwner;
    bool exists;
    bool existed;
  }

  mapping(address => Device) public devices;

  function addDevice(address _device, bool _isOwner) public;

  function removeDevice(address _device) public;

  function executeTransaction(address payable _recipient, uint256 _value, bytes memory _data) public returns (bytes memory _response);
}


contract DepositProxy {

    address payable public account;
    address payable public paymentManager;

    constructor (address payable _account, address payable _paymentManager) public {
        account = _account;
        paymentManager = _paymentManager;
    }

    function () payable external {
        address(account).transfer(msg.value);
        bytes memory empty;
        AbstractAccount(account).executeTransaction(paymentManager, msg.value, empty);
    }

}
2 Likes

Hi @tomnash welcome to the community :wave:

I have created a simple example contract to illustrate the problem.

When a wallet sends Ether to the contract (fallback function) gas is not estimated (above 21,000).

pragma solidity 0.5.10;

contract Fallback {

    function doStuff() public {
        for (uint i = 0; i < 1000; i++) {
        }
    }

    function () external payable {
        doStuff();
    }
}

As suggested in a Telegram group, when using MetaMask, if you also send data then gas is estimated.