How can i get transfers using watch_getTransfersByAddress?

post image

Hello builders!

If you have ever tried to get data on translations, you probably had to handle numerous block calls for a long time 😑

We at WatchData πŸ‘€Β can give you the ability to simplify this approach and get this data in 1 API call you only need to know the address you want to track. With our data you can create many different services, such as your monitoring service (pictured below):

post image

Looks interesting?

Well, let's look at the capabilities of the watch_getTransfersByAddress endpoint. To learn more, visit our Documentation.

post image

All you have to do is make a request and get information on how ETH and ERC20 transfers are received.

Let's now look at an example of how it all works.

Open the API client, we processed the request through Postman. If you're having trouble, check out our Quick start guide on how to get started with our API.

Request:

{
    "id": 1,
    "method": "watch_getTransfersByAddress",
    "jsonrpc": "2.0",
    "params": [
        {
        "addresses": "0xc7d15E3aE9442baD3E0B3689b835fDd035479B52",
        "transferDirection": "to",
        "fromBlock": 1,
        "offset": 0,
        "limit": 100
    }
    ]
}
  • For example you want to monitor your address for sending transactions . Suppose it is 0xc7d15E3aE9442baD3E0B3689b835fDd035479B52.

  • To get the transfers that were received at the specified address, add the parameter: "transferDirection": "to", and to get the transfers that were sent from this address, add the parameter "transferDirection": "from".

By the way, in the "addresses" parameter you can use several address values to get more information in one query, for example "addresses": ["0xc7d15E3aE9442baD3E0B3689b835fDd035479B52","0x6aE6d807E57964D5DaC79CF07D43AA0B458CB0dB"],

Now we make 1 request to the API and get information on all transfers of a given address.

Let's find out what we get in response.

Response:

{
    "id": 1,
    "jsonrpc": "2.0",
    "result": [
        {
            "blockNumber": 12591647,
            "blockTimestamp": "2021-06-08T04:07:30",
            "transactionIndex": 25,
            "logIndex": null,
            "contractAddress": null,
            "transferType": "trx",
            "from": "0xea674fdde714fd979de3edf0f56aa9716b898ec8",
            "to": "0xc7d15e3ae9442bad3e0b3689b835fdd035479b52",
            "value": 100055406833350373
        },
        {
            "blockNumber": 12664741,
            "blockTimestamp": "2021-06-19T12:13:15",
            "transactionIndex": 19,
            "logIndex": null,
            "contractAddress": null,
            "transferType": "trx",
            "from": "0xea674fdde714fd979de3edf0f56aa9716b898ec8",
            "to": "0xc7d15e3ae9442bad3e0b3689b835fdd035479b52",
            "value": 100050819506085117
        },
        {
            "blockNumber": 12731449,
            "blockTimestamp": "2021-06-29T21:56:32",
            "transactionIndex": 115,
            "logIndex": null,
            "contractAddress": null,
            "transferType": "trx",
            "from": "0xea674fdde714fd979de3edf0f56aa9716b898ec8",
            "to": "0xc7d15e3ae9442bad3e0b3689b835fdd035479b52",
            "value": 100022202551483258
 ............................................................................
        }
    ]
}

We obtained a dataset that transmits information on transfers.

From these values, we can determine that the:

  • transferType "trx" - is the native ETH token transfer.

  • Value - parameter gives the value with the uint256 format.

To convert this value into a usable format, we need to divide it by 10^18, because the decimals parameter at ETH = 18.

post image

⚠️ For different tokens there is a different decimals parameter be careful!

After processing the entire data set, we were able to get transfers that came and went from the address we specified. We have shown you just one example of how you can interact with a watch_getTransfersByAddress endpoint, try it yourself.

Log in to WatchData.

Our API is available in a free format, you can read more about the limits here β†’ Documentation.

  1. Join toΒ our Discord server

  2. Please leave your feedback in the #feedback channel. If you have any problems or you think that some functionality is not working correctly, we are waiting for your feedback.

  3. Want a new feature or you miss some functionality, tell us about it in the #general channel. We are always open to your ideas!