Import RC2771ContextUpgradeable - __ERC2771Context_init() undeclared identifier

I am developing an ERC20 smart contract based on the OpenZeppelin wizard template. It is burnable, mintable, pausable, ownable, and upgradable (transparent),
My goal here is to enable gas-free transfer for the dapp users - please take a look at "metaTransfer()" in Contracts/WrappedToken.sol.
Accordingly, I am importing "ERC2771ContextUpgradeable.sol" and calling "__ERC2771Context_init()" inside the initialize() function. However, I am getting Undeclared identifier error for "__ERC2771Context_init".

:1234: Code to reproduce

To reproduce, please refer to
I added contracts/WrappedToken.sol and test files for it under test/token.
However, the contract does not have any meta-tx related code yet, since I am getting an undeclared identifier error for "__ERC2771Context_init()".

:computer: Additional Question

I see that there are examples and workshops for ERC2771Context and MinimalForwarder.
Also, I am wondering if there are examples I can refer to for ERC2771ContextUpgradeable and MinimalForwarderUpgradeable. Examples for them will be a great help for me.

Please check the contract for the ERC2771Contextupgradeable, is one of the cases where it doesn't have an init function and that's why you get an identifier error.

For more information feel free to check this PR where we explain the reasoning behind it.

1 Like