2

I have a transaction hash and an RPC access to fully synced node. How to check if the token was actually moved? The transaction might be old, so there is no point in querying the contract.

  • If I understand correctly, the transaction from some account to ERC-20 compatible contract is merely a request for a contract to do the transfer.

  • If I lookup transaction receipt for this transaction in the block, it has status field. But, this only means that that no error was raised during execution of the contract.

  • If I look into events attached to the receipt, I might find a Transfer one but this only means that the contract emitted it, not that a account balance was actually changed.

0

The ERC20 contract should have a "balanceOf" function. You can call this function to see if your destination address has the balance after transfer.

var dest = "0x......"; //The address you want to transfer the token to

var tokenAbi='[......]';

var tokenAddress="0x25B1......3a0";//contract address

var tokenContract = chain3.mc.contract(tokenAbi);

tokenContract.at(tokenAddress).balanceOf(dest); //You should see some value here

  • 1
    The transaction is old, the balance now is totally different then the one at the time of the transaction. – atok Feb 24 '18 at 16:47
0

Did you try this https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethgettransaction if you see blocknumber it's mean the transaction it's complete

0

You can check the status field for the correct execution of the contract. The transfer function of ERC-20 either does a successful transaction or reverts. There is no way a transaction succeeds and no token transfer happens ( but it depends on how you write it).

But if you need info like sender, recipient, amount, then you can look at the receipt. Just make sure to fire event only after successful transfer in the contract. So if an event is emitted you can be sure that a transfer occurred.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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