I am trying to send ERC20 tokens from a contract to an account . This is the code that I have
IERC20 testToken = IERC20(tokenAddress);
testToken.transfer(accountAddress,amount);
The function to intitate the trasfer should ideally be called by someone else, lets call him "C" So
msg.sender != accountAddress
Is there a way I can make the msg.sender for the transfer function to be the contract itself instead of "C" ?
Also this function somehow works if I i call it from the account address ,i.e when msg.sender == accountAddress . How does that happen ,in this case the from and to fields should both be the same ,and no change in balance should happen ?
accountAddress
, no matter who calls it. That sounds like what you want : "I am trying to send ERC20 tokens from a contract to an account". no ? – SimonR