ethereumblockchainweb3jsether

How to identify an Ethereum smart contract transfer using RPC / web3js / ether.js?


If

1) Wallet A transfer 1 ether to Smart contract B

And at the same time

2) Smart contract B transfer the ether to wallet C

A->B->C

Using eth_getTransactionReceipt, how to check the amount has been sent to wallet C?


Solution

  • In order to use the eth_getTransactionReceipt method you need the TX number of the b -> c transfer. You can get the TX various ways but emitting an event is typically how you would do it. Once you have the TX you can call as below:

    curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["<TX number goes here>"],"id":1}'
    

    linked from : https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionreceipt