1
votes

I've cobbled together some code to send some tokens using web3.js 1.0.0-beta46 and then decided to try to send more token than I had in my wallet. to my great surprise the transaction send succeeded and I got a txid, but of course the transfer failed

here's the attempt (on Ropsten):

https://ropsten.etherscan.io/tx/0xaf2708dcc9b86b7cca0076e329a1e81fc28fdc4a97765b0a79544ec0685cfa69

now my question: how can I tell when the transfer succeeded? or for that matter how can I get the error message? etherscan merely indicates:

ERC-20 Token Transfer Error (Unable to locate Corresponding Transfer Event Logs), Check with Sender

1

1 Answers

1
votes

The most simple and straightforward way would be to check the balances of sender and receiver before and after the transfer.

Now about the failed transfer, after reading the contract I noticed that in the event of insufficient funds you simple return false, which makes a valid transaction. What you should do is revert the transactions using require to make the checks. That way an invalid transaction will be reverted by the EVM which will be recognized by etherscan and show that the transaction failed.