10 通过工厂部署的ERC20合约,owner不是发送者问题

通过工厂部署的ERC20合约,但是这个ERC20合约的owner是工厂地址 不是发送者,这个是什么问题 好像是is Ownable这个导致的? 怎么解决

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract TeamToken is ERC20, Ownable {
    constructor(
        string memory _name,
        string memory _symbol,
        uint8 _decimals,
        uint256 _supply,
        address _owner
    ) ERC20(_name, _symbol) {
        _mint(_owner, _supply * 10 **_decimals);
    }
}

pragma solidity ^0.8.0;

contract TeamTokenFactory is Ownable{
    address[] public allTeamTokens;
    address public feeWallet;
    uint256 private ethFee;

    event TeamTokenCreated(address token, string name, string symbol, uint8 decimals, uint256 supply);

    function setEthFee(uint256 _ethFee) public onlyOwner{
        ethFee = _ethFee;
    }

    function createTeamToken(string memory _name, string memory _symbol, uint8 _decimals, uint256 _supply,address _owner)payable external returns (address teamTokenAddr) {
        require(_decimals >=8 && _decimals <= 18, "Not valid decimals");
        TeamToken token = new TeamToken(_name, _symbol, _decimals, _supply, _owner);
        allTeamTokens.push(address(token));

        emit TeamTokenCreated(address(token), _name, _symbol, _decimals, _supply);

        payable(feeWallet).transfer(ethFee);

        return address(token);
    }

    function allTeamTokensLength() external view returns (uint256) {
        return allTeamTokens.length;
    }

}
请先 登录 后评论

最佳答案 2022-11-30 18:20

在合约TeamToken内实现 Ownable的方法,不要用 Ownable。很简单的,代码量很少。

请先 登录 后评论

其它 1 个回答

Meta - 风是自由的,你也是
请先 登录 后评论
  • 2 关注
  • 0 收藏,2029 浏览
  • 五哈希 提出于 2022-11-30 15:56