There are at least two major problems with your code that could explain why it doesn't work, but to now it for sure, I need source code of the smart contract referred by the
token variable. Here are the problems:
You ignore value returned by
token.transferFrom function. It is possible that the returned value if
false in some cases, which means failed transfer.
transferFrom function does not have any access control, which means that anybody may call it at steal the tokens.
While the second problem cannot lead to a failed transfer by itself, it makes me think that you misunderstand how
transferFrom function is working. Here is the scenario:
- Alice calls
transferFrom on your smart contract asking it to transfer some tokens from Bob to Carol.
- Your smart contract calls token smart contract asking it to transfer tokens from Bob to Carol.
- For token smart contract this call is not related to Alice in any way, as the call is originated from your smart contract, not from Alice's address.
- Token smart contract ensures, that Bob allowed your smart contract to take Bob's tokens.
- Token smart contract transfer tokens from Bob to Carol.
- Token smart contract reduces the number of tokens your smart contract is allowed to take from Bob.
I assume that at steps 4 and 6, there should be Alice instead of your smart contract, for the whole schema to work properly. In current implementation, anybody may call
transferFrom function of your smart contract asking to transfer Bob's token to arbitrary address, and, as Alice's address is never validated, the tokens will effectively be stolen.
So, failed transfer in your case may be caused by the fact that Bob allows Alice to take his tokens, while token smart contract checks whether Bob allowed your smart contract to take them.
OK. I looked into your transaction and it seems that you've passed the following values to
_values: [949999, 50000]
Address of your contract is
Addres of token smart contract is
You've sent transaction from the following address:
0x11b202de5b68ea66610b571b028dcca7743b64bc and this address is the owner of your smart contract.
So, for your transfers to succeed, the owner of
_from address should have allowed your smart contract to take at least 999999 tokens. However, actual allowance for
_owner: 0x18c7abf493c747f39ce006abeb9bd6d2592e833e and
_spender: 0x14a108a349cde4cb9019672f2489b003dc393049 is zero. This is why your transfers fail.