i want to make multiple transfer
this is my code

function transferMulti(address[] _to, uint[] _value) public returns(bool success) {
    require(_to.length == _value.length, "require _to[] size == _value[] size");

    for(uint8 i=0; i<_to.length; i++) {
      transfer(_to[i], _value[i]);

    return true;

but Actually, it was like Mint, Not Transfer...
how to maintain msg.sender?

closed as unclear what you're asking by shane, flygoing, GrandFleet, eth May 8 at 0:41

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


In standard ERC20 contracts the transfer() function can only be called by the account that owns the tokens. If you want to put a contract in the middle, the caller (msg.sender) of the transfer() function will become the contract, rather than the account that owns the tokens.

If the tokens are owned by an external account not a contract, they will have to either first transfer the tokens to the contract or call approve() to give the contract permission to move them with transferFrom().


You need to declare your transfer function (by transfer I mean transfer, not transferMulti) as public rather than as external.

When public function is called from within contract where it is declared, msg.sender is preserved, but for external functions it is overridden. See documentation for more details.

BTW, I see two major issues in your code: 1. you use uint8 for counter, thus you will get infinite loop in case _to.lengeth >= 256, and 2. You ignore value returned by transfer method.

  • thank you. i change code – JungTa Apr 30 at 4:03

I found a way
it use delegatecall
The important point is that you only need to write the data type of the parameter.

function transfer(address _to, uint256 _value) public returns (bool success) {

function transferMulti(address[] _to, uint256[] _value) public returns (bool success) {

    require(_to.length == _value.length, "_to.length == _value.length");

    for(uint i=0; i<_to.length; i++) {
        address(this).delegatecall(abi.encodeWithSignature("transfer(address,uint256)", _to[i], _value[i]));

    return true;

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