Proxy.sol error

Hello @thecil sir!
I receive the below error when I try to run truffle compile.
Can you check the code and let me know what is going wrong with it?
thanks.

This contract has a payable fallback function, but no receive ether function. Consider adding a receive ether function
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./Storage.sol";

contract Proxy is Storage {

  address currentAddress;


  constructor(address _currentAddress)  {
    owner = msg.sender;
    currentAddress = _currentAddress;
  }
  function upgrade(address _newAddress) public {
    require(msg.sender == owner);
    currentAddress = _newAddress;
  }

  //FALLBACK FUNCTION.
  fallback ()external  payable  {
    address implementation = currentAddress;
    require(currentAddress != address(0));
    bytes memory data = msg.data;

    

    //DELEGATECALL EVERY FUNCTION CALL
    assembly {
      let result := delegatecall(gas(), implementation, add(data, 0x20), mload(data), 0, 0)
      let size := returndatasize()
      let ptr := mload(0x40)
      returndatacopy(ptr, 0, size)
      switch result
      case 0 {revert(ptr, size)}
      default {return(ptr, size)}
    }
  }
}
1 Like

try to add this function before fallback

receive() external payable {}

Carlos Z

Thank you, sir :slight_smile:

Noted with thanks

Regards
ishaaq

1 Like