ERC2771Upgradeable and ContraxUpgradeable metatx incompatibility

I am trying to implement metxtx on my upgradeable smart contracts which is inheriting from several openzeppling smart contracts.

pragma solidity ^0.8.0;

import "./AmaFansLib.sol";
import "./AmaFansNFT.sol";
import "@openzeppelin/contracts-upgradeable@4.4.1/metatx/ERC2771ContextUpgradeable.sol";
contract AmaFansCoreStorage is ERC2771ContextUpgradeable{ 
      //contract code here
}



contract AmaFansCore is Initializable, 
                        PausableUpgradeable,
                        AccessControlEnumerableUpgradeable, 
                        ReentrancyGuardUpgradeable,
                        AmaFansCoreEvents,
                        AmaFansCoreStorage{
    using AmaFansLib for *;
    using Counters for Counters.Counter;
    Counters.Counter private socialNetworkTracker;
    

    function _msgSender() 
            internal 
            override(ERC2771ContextUpgradeable, ContextUpgradeable) 
            returns (bytes calldata) {
                super._msgSender();
    }

    function _msgData() 
            internal 
            view  
            override(ERC2771ContextUpgradeable, ContextUpgradeable) 
            returns (bytes calldata) {
                super._msgData();
    }

}

I couldnt get it working as it is giving me this error

TypeError: Overriding function return types differ.
--> AmaFansCore.sol:41:5:
|
41 | function _msgSender()
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Overridden function is here:
--> @openzeppelin/contracts-upgradeable@4.4.1/utils/ContextUpgradeable.sol:24:5:
|
24 | function _msgSender() internal view virtual returns (address) {
| ^ (Relevant source part starts here and spans across multiple lines).

Without Meta-tx everything was working fine.
I tried implementing BaseRelayRecipient.sol from opensgsn but got into the same problem.

Please help me here?

Hi @GraphicalDot.

You're simply missing the return keyword so your _msgSender function doesn't return anything. The fix:

    function _msgSender() 
            internal 
            override(ERC2771ContextUpgradeable, ContextUpgradeable) 
            returns (bytes calldata) {
-               super._msgSender();
+               return super._msgSender();
    }
1 Like