Ethereum ETH transfer to contract not working

53 views Asked by At

We're writing some contracts to use the Account Abstraction (ERC-4337) features on Ethereum. In particular we're writing a contract that will double as an account factory and a paymaster. Here's the essential parts relating to my question

contract AccountFactory is IPaymaster, Ownable
{

    address private Entrypoint;

    constructor(address _entrypoint)
    {
        Entrypoint = _entrypoint;
    }

    receive() external payable {}
    fallback() external payable {}

}

As the contract will also be a paymaster and adding stakes to the Entrypoint whenever necessary it needs to be able to hold ETH, which is why we've added the receive and fallback functions.

The problem is transferring ETH to the contract fails.

We're using Nethereum and the following:

var transaction = await web3.Eth.GetEtherTransferService()
          .TransferEtherAndWaitForReceiptAsync(address, value);

So, it's literally as basic as it gets.

This works with an EOA address, but as soon as we pass the deployed address of the AccountFactory contract it fails. Strangely the logsbloom is just 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Any ideas why the contract can't receive a transfer?

1

There are 1 answers

1
matt sharp On

Ensure your contract has the following:

function () payable {
    // code if required
}