Set owner as tx.origin on deploy


We are trying to set the owner as tx.origin on deploy, as we use a seperate factory to deploy the contract, that we do not control. In order for the owner to be set to the wallet owner, tx.origin is needed.

Is there a way to change msg.sender to tx.origin for ownable in OZ?


// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.9;

import "hardhat/console.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract TestCoin is ERC20, ERC20Burnable, Pausable, Ownable {
    constructor() ERC20("TestCoin2", "TEST") {
        _mint(tx.origin, 69000000000000000 * 10 ** decimals());

    function pause() public onlyOwner {

    function unpause() public onlyOwner {

    function _beforeTokenTransfer(address from, address to, uint256 amount)
        super._beforeTokenTransfer(from, to, amount);