While I am making a toy project that has some web3 feature, I am trying to make ERC20 token that the issuer can control the tokens wherever they are. For example, the issuer can send the tokens from user A to user B without getting allowance. Since it also has all ERC20 features, I am considering to add a function "trasnferFromOwner" to the normal ERC20 contract such that

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

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

contract MyToken is ERC20, Ownable {
    constructor() ERC20("MyToken", "MTK") {
        _mint(msg.sender, 10000 * 10 ** decimals());

    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);

    function transferFromIssuer(address sender, address recipient, uint256 amount) public onlyOwner {

But I have no idea where to start and how I would make this function as I wish. Please help. Thank you.

1 Answer 1


As a recommendation you can implement the transferFromOwner function like that

function transferFromOwner(address sender, address recipient, uint256 amount) public onlyOwner {
    // First, check that the contract owner has sufficient allowance for the sender
    require(allowance(owner, sender) >= amount, "Insufficient allowance for sender");

    // Then, transfer the tokens on behalf of the sender
    _transferFrom(sender, recipient, amount);
  • it's important to ensure that the contract owner is trusted and that proper access controls are in place to prevent misuse. Jan 5, 2023 at 6:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.