How can a factory deploy a BeaconProxy that has an implementation contract that inherits Meta-tx library ERC2771ContextUpgradeable?

Hi OZ team,

Noticed that ERC2771ContextUpgradeable does not come with an _init() and was wondering how to get a factory to deploy a BeaconProxy that takes in the function call to initiate the implementation contract that inherits ERC2771ContextUpgradeable that its UpgradeableBeacon is pointing to?

Simplified AContract contract code:

contract AContract is ERC2771ContextUpgradeable, AccessControlEnumerableUpgradeable {

    constructor(address trustedForwarder) 
        ERC2771ContextUpgradeable(trustedForwarder) {

    /// Initializes the contract
    /// @dev Uses the initializer modifier to to ensure the contract is only initialized once
    function initialize() initializer public {


Simplified AFactory contract:

contract AFactory {

    function createAContract(address trustedForwarder) public {
            BeaconProxy beaconProxy = new BeaconProxy(beaconAddress, 
            abi.encodeWithSelector(AContract(address(0)).initialize.selector, trustedForwarder));

1 Like

The contract doesn't have an init but it has a constructor:

This is because the trusted forwarder is stored as an immutable variable. You need to add a constructor in your own contract, annotate it with /// @custom:oz-upgrades-unsafe-allow constructor, and if it has arguments you have to use the constructorArgs option in our Upgrades plugin. Look it up in the docs.

1 Like