In addition to the previously mentioned functions, ERC20 also implements some events for logging:
event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
These events can be listened to from your application to provide a seamless UI for the user. This can help notify the users of tokens received or approved:
tokenContract.events.Transfer({
filter: { },
fromBlock: 0
})
.on('data', function(event){
// ...
})
.on('changed', function(event){
// ...
})
.on('error',function(event){
// ...
});