Harmony JS SDK: Getting List of Transactions by Address

I am playing around with the js sdk provided by harmony and was wondering if anyone knows how I would collected all the transactions given an address? I don’t see any methods in the sdk packages that provide this functionality.

I have basically figured out that I need to parse through every block and inspect the “from” and “to” on each transaction until I have found every transaction for that address (as determined by getTransactionCount).

To do this efficiently, I realized it would be better if I could request multiple blocks in one call instead of calling one block at a time through the getBlockByNumber method.

I opened a PR which adds the hmy_getBlocks API method to the js SDK.

Maybe a bit late but you can use this method to get transactions

curl --location --request POST 'https://rpc.s0.t.hmny.io' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "hmyv2_getTransactionsHistory",
    "params": [
        {
            "address": "one15vlc8yqstm9algcf6e94dxqx6y04jcsqjuc3gt",
            "pageIndex": 0,
            "pageSize": 1,
            "fullTx": true,
            "txType": "ALL",
            "order": "ASC"
        }
    ]
}'

From: Harmony Node API

2 Likes