Receive() function in proxy contracts

/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if 
   call data is empty.
*/
    receive() external payable virtual {
        _fallback();
    }

The implementation of the proxies has a receive() payable virtual function as shown above, however this function call the fallback. receive is only executed when the datacall is empty, therefore why the implementation redirects to the fallback?

This creates issues if the contracts is expected to receive native tokens and it is call from another contract using address.transfer due to the 2200 gas stipend.

The function is virtual and can be override, but how do you override the proxy if you are using hardhat-upgardes, is it possible to do that?

Thanks in advance.

@openzeppelin/hardhat-upgrades doesn't allow customizing the proxy code at this point.

If you need to enable receive, you would need to deploy the proxy manually.

1 Like