0

I have downloaded the contents of each historical Ethereum block (starting with block 0) by calling eth_getBlockByNumber for every single block.

I want to write a script that iterates over each transaction in each block, in chronological order, and updates an internal data structure which maps each address to its ETH balance.

If I were to do this with any ERC20 token, I would simply process each Transfer log and update accordingly. However, there are no logs for ETH transfers, so I am not sure how to do this. Any thoughts would be greatly appreciated!

2 Answers 2

1

Dev Advocate at Chainstack here.

This task is relatively complex if you want to scrape and index the chain from scratch.

You can achieve this by tracing each transaction using trace_transaction

Let's take this example using web3.py:

Note that you need to enable the tracing namespace on the Erigon client. You can do it with Chainstack following the docs here, but other providers might also have the option.

from web3 import Web3
import json

# Configuration
NODE_URL = "RPC_URL_WITH_TRACES_ENABLED"  # Replace with your Ethereum node URL

TX_HASHES = [
    "0x7d19e5aed44365b7054290f0bccf7f88efa0919a89df2070e2f816199e6a3461",
    "0x54342c2d2327e2872bf770567ac8a01afc9af57cc4ecfe86e3cfe006adee5028",
    "0xfe5372220da4e2ce2d7d3976d41fbdf4d0d5909aee96135a6fbfeca79b385cf8",
    "0x8c7dd9f6c3aec7e3e49cbf95eb602ff356929de72179515b5cc0270b64d83a32",
    "0xcbe55b42c1e9dfb7eb807496edd06e5f38d64548a9c29e653f2e523016d67a1e",
    "0xd2d6aec5f02ef4875c069628d6826a111249040cd9652c5071a65dc6ab87841c",
    "0x119f88f59d0e726c9fa733ff7e909982d65e10c99caa5f4848df4e4c1253be56",
    "0x6ee6328db61a897928ecbbb3b179d06dead335669ca67e60e89793103bc27b13",
    "0x004903819dbb2ce40e3eaf6bda8b1f9da94eaf6ae8cd0f1061aed1ec448cb664",
    "0xd1d0f89ee9c42b5eb55a5125b67f135ef404e934e8c2e585c82a6671fa73cce4",
    "0xb055f43cd396985f8514607936921b314ae726ec2052791fffec656bcf8cb69d",
    "0x21fb0d311272b3182c4a486a5226aedccdfea57af8818d67a57e9c28ee4b0d71",
    "0x828d35754b69f4a5f6abcd45408ecf86733bf436e94cfc006fa4047747a9be0a",
]


# Initialize Web3 connection
web3 = Web3(Web3.HTTPProvider(NODE_URL))
if not web3.is_connected():
    raise Exception("Failed to connect to Ethereum node")

# Initialize balances dictionary
balances = {}


def wei_to_ether(wei_value):
    """Convert Wei to Ether."""
    return wei_value / 10**18


def update_balances(from_address, to_address, amount):
    """Update balances based on a transaction."""
    balances[from_address] = balances.get(from_address, 0) - amount
    balances[to_address] = balances.get(to_address, 0) + amount


def trace_transaction(tx_hash):
    """Use trace_transaction to get detailed transaction info."""
    try:
        traces = web3.provider.make_request("trace_transaction", [tx_hash])
        return traces["result"]
    except Exception as e:
        print(f"Error tracing transaction {tx_hash}: {e}")
        return None


def process_trace(trace_data, tx_hash):
    """Process trace data to update balances."""
    for trace in trace_data:
        action = trace.get("action", {})
        from_address = action.get("from")
        to_address = action.get("to")
        value = int(action.get("value", "0x0"), 16)  # Convert hex value to integer

        # Enhanced debugging information
        print(
            f"TxHash: {tx_hash}, Trace: from {from_address} to {to_address}, value {value}."
        )

        if value > 0 and from_address and to_address:
            update_balances(from_address, to_address, value)

        # Further logic for gas fees and other special cases


def main():
    for tx_hash in TX_HASHES:
        trace_data = trace_transaction(tx_hash)
        if trace_data:
            process_trace(trace_data, tx_hash)

    # Convert Wei balances to Ether and print
    balances_in_ether = {
        addr: wei_to_ether(balance) for addr, balance in balances.items()
    }
    print(json.dumps(balances_in_ether, indent=4))


if __name__ == "__main__":
    main()

This is what it does and its logic:

Script Workflow

  1. Iterating Over Transactions:

    • The script iterates over each transaction hash in the TX_HASHES list.
    • For each transaction hash, it requests the Ethereum node for trace data.
  2. Processing Transaction Traces:

    • Each transaction's trace data is processed to understand the flow of Ether.
    • This involves identifying the sender (from) and receiver (to) addresses and the value transferred in each transaction component.
  3. Updating Balances:

    • Based on the extracted data, the script updates the balances dictionary to reflect the changes in Ether balances for each address involved.
  4. Debugging Information:

    • The script prints out details for each trace, including transaction hash, sender, receiver, and value. This helps in debugging and verifying the script's functionality.
  5. Final Output:

    • After processing all transactions, the script converts the balance changes from Wei to Ether.
    • It then prints the final balance changes in a human-readable format (Ether).

Please note that this is a proof of concept, and it will require more testing to ensure accuracy. But it's a good start on how to approach such a big task.

The output will look like this:

TxHash: 0x7d19e5aed44365b7054290f0bccf7f88efa0919a89df2070e2f816199e6a3461, Trace: from 0x4eb8769a89b91b60a14ad1d30f2b136d9cf61b18 to 0xcb83ca9633ad057bd88a48a5b6e8108d97ad4472, value 0.
TxHash: 0x7d19e5aed44365b7054290f0bccf7f88efa0919a89df2070e2f816199e6a3461, Trace: from 0xcb83ca9633ad057bd88a48a5b6e8108d97ad4472 to 0x2b68ead18db86cd6130df53c4b6c3c77332a3351, value 0.
TxHash: 0x7d19e5aed44365b7054290f0bccf7f88efa0919a89df2070e2f816199e6a3461, Trace: from 0xcb83ca9633ad057bd88a48a5b6e8108d97ad4472 to 0x188e817b02e635d482ae4d81e25dda98a97c4a42, value 0.
TxHash: 0x7d19e5aed44365b7054290f0bccf7f88efa0919a89df2070e2f816199e6a3461, Trace: from 0xcb83ca9633ad057bd88a48a5b6e8108d97ad4472 to 0x2b68ead18db86cd6130df53c4b6c3c77332a3351, value 0.
TxHash: 0x7d19e5aed44365b7054290f0bccf7f88efa0919a89df2070e2f816199e6a3461, Trace: from 0x2b68ead18db86cd6130df53c4b6c3c77332a3351 to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0x7d19e5aed44365b7054290f0bccf7f88efa0919a89df2070e2f816199e6a3461, Trace: from 0x2b68ead18db86cd6130df53c4b6c3c77332a3351 to 0x188e817b02e635d482ae4d81e25dda98a97c4a42, value 0.
TxHash: 0x7d19e5aed44365b7054290f0bccf7f88efa0919a89df2070e2f816199e6a3461, Trace: from 0x2b68ead18db86cd6130df53c4b6c3c77332a3351 to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0x54342c2d2327e2872bf770567ac8a01afc9af57cc4ecfe86e3cfe006adee5028, Trace: from 0xd9c4434a5294bd82979c73f52d239bb2930f7429 to 0x6719c6ebf80d6499ca9ce170cda72beb3f1d1a54, value 0.
TxHash: 0x54342c2d2327e2872bf770567ac8a01afc9af57cc4ecfe86e3cfe006adee5028, Trace: from 0x6719c6ebf80d6499ca9ce170cda72beb3f1d1a54 to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0x54342c2d2327e2872bf770567ac8a01afc9af57cc4ecfe86e3cfe006adee5028, Trace: from 0x6719c6ebf80d6499ca9ce170cda72beb3f1d1a54 to 0x2b68ead18db86cd6130df53c4b6c3c77332a3351, value 0.
TxHash: 0x54342c2d2327e2872bf770567ac8a01afc9af57cc4ecfe86e3cfe006adee5028, Trace: from 0x2b68ead18db86cd6130df53c4b6c3c77332a3351 to 0x188e817b02e635d482ae4d81e25dda98a97c4a42, value 0.
TxHash: 0x54342c2d2327e2872bf770567ac8a01afc9af57cc4ecfe86e3cfe006adee5028, Trace: from 0x2b68ead18db86cd6130df53c4b6c3c77332a3351 to 0x188e817b02e635d482ae4d81e25dda98a97c4a42, value 0.
TxHash: 0x54342c2d2327e2872bf770567ac8a01afc9af57cc4ecfe86e3cfe006adee5028, Trace: from 0x2b68ead18db86cd6130df53c4b6c3c77332a3351 to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0xfe5372220da4e2ce2d7d3976d41fbdf4d0d5909aee96135a6fbfeca79b385cf8, Trace: from 0xf5213a6a2f0890321712520b8048d9886c1a9900 to 0xe592427a0aece92de3edee1f18e0157c05861564, value 0.
TxHash: 0xfe5372220da4e2ce2d7d3976d41fbdf4d0d5909aee96135a6fbfeca79b385cf8, Trace: from 0xe592427a0aece92de3edee1f18e0157c05861564 to 0x465e56cd21ad47d4d4790f17de5e0458f20c3719, value 0.
TxHash: 0xfe5372220da4e2ce2d7d3976d41fbdf4d0d5909aee96135a6fbfeca79b385cf8, Trace: from 0x465e56cd21ad47d4d4790f17de5e0458f20c3719 to 0xd1d2eb1b1e90b638588728b4130137d262c87cae, value 0.
TxHash: 0xfe5372220da4e2ce2d7d3976d41fbdf4d0d5909aee96135a6fbfeca79b385cf8, Trace: from 0xd1d2eb1b1e90b638588728b4130137d262c87cae to 0x8d92a6812b3da2346883f0631910c96cb9c5a5f9, value 0.
TxHash: 0xfe5372220da4e2ce2d7d3976d41fbdf4d0d5909aee96135a6fbfeca79b385cf8, Trace: from 0x465e56cd21ad47d4d4790f17de5e0458f20c3719 to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0xfe5372220da4e2ce2d7d3976d41fbdf4d0d5909aee96135a6fbfeca79b385cf8, Trace: from 0x465e56cd21ad47d4d4790f17de5e0458f20c3719 to 0xe592427a0aece92de3edee1f18e0157c05861564, value 0.
TxHash: 0xfe5372220da4e2ce2d7d3976d41fbdf4d0d5909aee96135a6fbfeca79b385cf8, Trace: from 0xe592427a0aece92de3edee1f18e0157c05861564 to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0xfe5372220da4e2ce2d7d3976d41fbdf4d0d5909aee96135a6fbfeca79b385cf8, Trace: from 0x465e56cd21ad47d4d4790f17de5e0458f20c3719 to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0x8c7dd9f6c3aec7e3e49cbf95eb602ff356929de72179515b5cc0270b64d83a32, Trace: from 0x3bb536776f0ce9dcbf486ef2da6166c4c480b985 to 0xbc55cb1217b214e8bfd17449ba371cd1fddf5f7a, value 0.
TxHash: 0xcbe55b42c1e9dfb7eb807496edd06e5f38d64548a9c29e653f2e523016d67a1e, Trace: from 0xa4606dfaedc482670ef4567187645b4052e189ab to 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e, value 200000000000000000.
TxHash: 0xcbe55b42c1e9dfb7eb807496edd06e5f38d64548a9c29e653f2e523016d67a1e, Trace: from 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e to 0x6599ae06914f1f5ec0053d3f475348d40e608442, value 200000000000000000.
TxHash: 0xcbe55b42c1e9dfb7eb807496edd06e5f38d64548a9c29e653f2e523016d67a1e, Trace: from 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 200000000000000000.
TxHash: 0xcbe55b42c1e9dfb7eb807496edd06e5f38d64548a9c29e653f2e523016d67a1e, Trace: from 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0xcbe55b42c1e9dfb7eb807496edd06e5f38d64548a9c29e653f2e523016d67a1e, Trace: from 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e to 0xcc6773f710b7f2a2357e228609c114f8fae04b61, value 0.
TxHash: 0xcbe55b42c1e9dfb7eb807496edd06e5f38d64548a9c29e653f2e523016d67a1e, Trace: from 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e to 0xc0920dbec5d5c6fe9b7a9709277decbb37bb6716, value 0.
TxHash: 0xcbe55b42c1e9dfb7eb807496edd06e5f38d64548a9c29e653f2e523016d67a1e, Trace: from 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0xcbe55b42c1e9dfb7eb807496edd06e5f38d64548a9c29e653f2e523016d67a1e, Trace: from 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e to 0xc0920dbec5d5c6fe9b7a9709277decbb37bb6716, value 0.
TxHash: 0xcbe55b42c1e9dfb7eb807496edd06e5f38d64548a9c29e653f2e523016d67a1e, Trace: from 0xc0920dbec5d5c6fe9b7a9709277decbb37bb6716 to 0xcc6773f710b7f2a2357e228609c114f8fae04b61, value 0.
TxHash: 0xcbe55b42c1e9dfb7eb807496edd06e5f38d64548a9c29e653f2e523016d67a1e, Trace: from 0xc0920dbec5d5c6fe9b7a9709277decbb37bb6716 to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0xcbe55b42c1e9dfb7eb807496edd06e5f38d64548a9c29e653f2e523016d67a1e, Trace: from 0xc0920dbec5d5c6fe9b7a9709277decbb37bb6716 to 0xcc6773f710b7f2a2357e228609c114f8fae04b61, value 0.
TxHash: 0xcbe55b42c1e9dfb7eb807496edd06e5f38d64548a9c29e653f2e523016d67a1e, Trace: from 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e to 0xcc6773f710b7f2a2357e228609c114f8fae04b61, value 0.
TxHash: 0xd2d6aec5f02ef4875c069628d6826a111249040cd9652c5071a65dc6ab87841c, Trace: from 0x77ad3a15b78101883af36ad4a875e17c86ac65d1 to 0x00000000a991c429ee2ec6df19d40fe0c80088b8, value 234926567.
TxHash: 0xd2d6aec5f02ef4875c069628d6826a111249040cd9652c5071a65dc6ab87841c, Trace: from 0x00000000a991c429ee2ec6df19d40fe0c80088b8 to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0xd2d6aec5f02ef4875c069628d6826a111249040cd9652c5071a65dc6ab87841c, Trace: from 0x00000000a991c429ee2ec6df19d40fe0c80088b8 to 0xcd02a882804f3eb0f2d80f94a04defcea038359f, value 0.
TxHash: 0xd2d6aec5f02ef4875c069628d6826a111249040cd9652c5071a65dc6ab87841c, Trace: from 0xcd02a882804f3eb0f2d80f94a04defcea038359f to 0x4c45bbec2ff7810ef4a77ad7bd4757c446fe4155, value 0.
TxHash: 0xd2d6aec5f02ef4875c069628d6826a111249040cd9652c5071a65dc6ab87841c, Trace: from 0xcd02a882804f3eb0f2d80f94a04defcea038359f to 0x4c45bbec2ff7810ef4a77ad7bd4757c446fe4155, value 0.
TxHash: 0xd2d6aec5f02ef4875c069628d6826a111249040cd9652c5071a65dc6ab87841c, Trace: from 0xcd02a882804f3eb0f2d80f94a04defcea038359f to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0x119f88f59d0e726c9fa733ff7e909982d65e10c99caa5f4848df4e4c1253be56, Trace: from 0xd92798abca9b68a122ffd7363541a19bee517786 to 0x881d40237659c251811cec9c364ef91dc08d300c, value 950000000000000000.
TxHash: 0x119f88f59d0e726c9fa733ff7e909982d65e10c99caa5f4848df4e4c1253be56, Trace: from 0x881d40237659c251811cec9c364ef91dc08d300c to 0x74de5d4fcbf63e00296fd95d33236b9794016631, value 950000000000000000.
TxHash: 0x119f88f59d0e726c9fa733ff7e909982d65e10c99caa5f4848df4e4c1253be56, Trace: from 0x74de5d4fcbf63e00296fd95d33236b9794016631 to 0x7cdf68ce9a05413cbb76cb7f80eaf415a826e313, value 950000000000000000.
TxHash: 0x119f88f59d0e726c9fa733ff7e909982d65e10c99caa5f4848df4e4c1253be56, Trace: from 0x74de5d4fcbf63e00296fd95d33236b9794016631 to 0x1111111254eeb25477b68fb85ed929f73a960582, value 941687500000000000.
TxHash: 0x119f88f59d0e726c9fa733ff7e909982d65e10c99caa5f4848df4e4c1253be56, Trace: from 0x1111111254eeb25477b68fb85ed929f73a960582 to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 941687500000000000.
TxHash: 0x119f88f59d0e726c9fa733ff7e909982d65e10c99caa5f4848df4e4c1253be56, Trace: from 0x1111111254eeb25477b68fb85ed929f73a960582 to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0x119f88f59d0e726c9fa733ff7e909982d65e10c99caa5f4848df4e4c1253be56, Trace: from 0x1111111254eeb25477b68fb85ed929f73a960582 to 0xcd02a882804f3eb0f2d80f94a04defcea038359f, value 0.
TxHash: 0x119f88f59d0e726c9fa733ff7e909982d65e10c99caa5f4848df4e4c1253be56, Trace: from 0x1111111254eeb25477b68fb85ed929f73a960582 to 0xcd02a882804f3eb0f2d80f94a04defcea038359f, value 0.
TxHash: 0x119f88f59d0e726c9fa733ff7e909982d65e10c99caa5f4848df4e4c1253be56, Trace: from 0xcd02a882804f3eb0f2d80f94a04defcea038359f to 0x4c45bbec2ff7810ef4a77ad7bd4757c446fe4155, value 0.
TxHash: 0x119f88f59d0e726c9fa733ff7e909982d65e10c99caa5f4848df4e4c1253be56, Trace: from 0xcd02a882804f3eb0f2d80f94a04defcea038359f to 0x4c45bbec2ff7810ef4a77ad7bd4757c446fe4155, value 0.
TxHash: 0x119f88f59d0e726c9fa733ff7e909982d65e10c99caa5f4848df4e4c1253be56, Trace: from 0xcd02a882804f3eb0f2d80f94a04defcea038359f to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0x119f88f59d0e726c9fa733ff7e909982d65e10c99caa5f4848df4e4c1253be56, Trace: from 0x74de5d4fcbf63e00296fd95d33236b9794016631 to 0xf326e4de8f66a0bdc0970b79e0924e33c79f1915, value 8312500000000000.
TxHash: 0x119f88f59d0e726c9fa733ff7e909982d65e10c99caa5f4848df4e4c1253be56, Trace: from 0xf326e4de8f66a0bdc0970b79e0924e33c79f1915 to 0xd9db270c1b5e3bd161e8c8503c55ceabee709552, value 8312500000000000.
TxHash: 0x119f88f59d0e726c9fa733ff7e909982d65e10c99caa5f4848df4e4c1253be56, Trace: from 0x74de5d4fcbf63e00296fd95d33236b9794016631 to 0x4c45bbec2ff7810ef4a77ad7bd4757c446fe4155, value 0.
TxHash: 0x119f88f59d0e726c9fa733ff7e909982d65e10c99caa5f4848df4e4c1253be56, Trace: from 0x74de5d4fcbf63e00296fd95d33236b9794016631 to 0x4c45bbec2ff7810ef4a77ad7bd4757c446fe4155, value 0.
TxHash: 0x6ee6328db61a897928ecbbb3b179d06dead335669ca67e60e89793103bc27b13, Trace: from 0x77ad3a15b78101883af36ad4a875e17c86ac65d1 to 0x00000000a991c429ee2ec6df19d40fe0c80088b8, value 237933011.
TxHash: 0x6ee6328db61a897928ecbbb3b179d06dead335669ca67e60e89793103bc27b13, Trace: from 0x00000000a991c429ee2ec6df19d40fe0c80088b8 to 0x4c45bbec2ff7810ef4a77ad7bd4757c446fe4155, value 0.
TxHash: 0x6ee6328db61a897928ecbbb3b179d06dead335669ca67e60e89793103bc27b13, Trace: from 0x00000000a991c429ee2ec6df19d40fe0c80088b8 to 0xcd02a882804f3eb0f2d80f94a04defcea038359f, value 0.
TxHash: 0x6ee6328db61a897928ecbbb3b179d06dead335669ca67e60e89793103bc27b13, Trace: from 0xcd02a882804f3eb0f2d80f94a04defcea038359f to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0x6ee6328db61a897928ecbbb3b179d06dead335669ca67e60e89793103bc27b13, Trace: from 0xcd02a882804f3eb0f2d80f94a04defcea038359f to 0x4c45bbec2ff7810ef4a77ad7bd4757c446fe4155, value 0.
TxHash: 0x6ee6328db61a897928ecbbb3b179d06dead335669ca67e60e89793103bc27b13, Trace: from 0xcd02a882804f3eb0f2d80f94a04defcea038359f to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0x004903819dbb2ce40e3eaf6bda8b1f9da94eaf6ae8cd0f1061aed1ec448cb664, Trace: from 0xd4b1d3df01d518247ebacfa116b9ccc295d37f65 to 0xcc6773f710b7f2a2357e228609c114f8fae04b61, value 0.
TxHash: 0xd1d0f89ee9c42b5eb55a5125b67f135ef404e934e8c2e585c82a6671fa73cce4, Trace: from 0x1d9262af4e61af885ef60ab76e35454b02b82a50 to 0x6f1cdbbb4d53d226cf4b917bf768b94acbab6168, value 12536.
TxHash: 0xd1d0f89ee9c42b5eb55a5125b67f135ef404e934e8c2e585c82a6671fa73cce4, Trace: from 0x6f1cdbbb4d53d226cf4b917bf768b94acbab6168 to 0x12cc685eeb95d3fcdfae0a996e214e51fa6f7548, value 0.
TxHash: 0xd1d0f89ee9c42b5eb55a5125b67f135ef404e934e8c2e585c82a6671fa73cce4, Trace: from 0x12cc685eeb95d3fcdfae0a996e214e51fa6f7548 to 0x00c83aecc790e8a4453e5dd3b0b4b3680501a7a7, value 0.
TxHash: 0xd1d0f89ee9c42b5eb55a5125b67f135ef404e934e8c2e585c82a6671fa73cce4, Trace: from 0x00c83aecc790e8a4453e5dd3b0b4b3680501a7a7 to 0x1820a4b7618bde71dce8cdc73aab6c95905fad24, value 0.
TxHash: 0xd1d0f89ee9c42b5eb55a5125b67f135ef404e934e8c2e585c82a6671fa73cce4, Trace: from 0x00c83aecc790e8a4453e5dd3b0b4b3680501a7a7 to 0xc04a10fd5e6513242558f47331568abd6185a310, value 0.
TxHash: 0xd1d0f89ee9c42b5eb55a5125b67f135ef404e934e8c2e585c82a6671fa73cce4, Trace: from 0xc04a10fd5e6513242558f47331568abd6185a310 to 0x538d2b8cc2335c9495a6bfc9a57eb8e9c389d5f1, value 0.
TxHash: 0xd1d0f89ee9c42b5eb55a5125b67f135ef404e934e8c2e585c82a6671fa73cce4, Trace: from 0x00c83aecc790e8a4453e5dd3b0b4b3680501a7a7 to 0x4ee5f270572285776814e32952446e9b7ee15c86, value 0.
TxHash: 0xd1d0f89ee9c42b5eb55a5125b67f135ef404e934e8c2e585c82a6671fa73cce4, Trace: from 0x4ee5f270572285776814e32952446e9b7ee15c86 to 0x2db9ccb342003421544faba8cdf670ab922de5d3, value 0.
TxHash: 0xd1d0f89ee9c42b5eb55a5125b67f135ef404e934e8c2e585c82a6671fa73cce4, Trace: from 0x4ee5f270572285776814e32952446e9b7ee15c86 to 0x06dd71dab27c1a3e0b172d53735f00bf1a66eb79, value 0.
TxHash: 0xd1d0f89ee9c42b5eb55a5125b67f135ef404e934e8c2e585c82a6671fa73cce4, Trace: from 0x06dd71dab27c1a3e0b172d53735f00bf1a66eb79 to 0xd214df04c80569d6207c687f083b3c51dc7dd717, value 0.
TxHash: 0xd1d0f89ee9c42b5eb55a5125b67f135ef404e934e8c2e585c82a6671fa73cce4, Trace: from 0x00c83aecc790e8a4453e5dd3b0b4b3680501a7a7 to 0x1820a4b7618bde71dce8cdc73aab6c95905fad24, value 0.
TxHash: 0xd1d0f89ee9c42b5eb55a5125b67f135ef404e934e8c2e585c82a6671fa73cce4, Trace: from 0x12cc685eeb95d3fcdfae0a996e214e51fa6f7548 to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0xd1d0f89ee9c42b5eb55a5125b67f135ef404e934e8c2e585c82a6671fa73cce4, Trace: from 0x12cc685eeb95d3fcdfae0a996e214e51fa6f7548 to 0x6f1cdbbb4d53d226cf4b917bf768b94acbab6168, value 0.
TxHash: 0xd1d0f89ee9c42b5eb55a5125b67f135ef404e934e8c2e585c82a6671fa73cce4, Trace: from 0x6f1cdbbb4d53d226cf4b917bf768b94acbab6168 to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0xd1d0f89ee9c42b5eb55a5125b67f135ef404e934e8c2e585c82a6671fa73cce4, Trace: from 0x12cc685eeb95d3fcdfae0a996e214e51fa6f7548 to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0xb055f43cd396985f8514607936921b314ae726ec2052791fffec656bcf8cb69d, Trace: from 0x1529282ea2d39c1a7a78608c0d0cab72a265196d to 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e, value 50000000000000000.
TxHash: 0xb055f43cd396985f8514607936921b314ae726ec2052791fffec656bcf8cb69d, Trace: from 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e to 0x6599ae06914f1f5ec0053d3f475348d40e608442, value 50000000000000000.
TxHash: 0xb055f43cd396985f8514607936921b314ae726ec2052791fffec656bcf8cb69d, Trace: from 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 50000000000000000.
TxHash: 0xb055f43cd396985f8514607936921b314ae726ec2052791fffec656bcf8cb69d, Trace: from 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0xb055f43cd396985f8514607936921b314ae726ec2052791fffec656bcf8cb69d, Trace: from 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e to 0x883f5df5f8785d9c54b927b1362332b06b69bb56, value 0.
TxHash: 0xb055f43cd396985f8514607936921b314ae726ec2052791fffec656bcf8cb69d, Trace: from 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e to 0x95e3d0fb07a33737e02fcfa0b14575f778e3391f, value 0.
TxHash: 0xb055f43cd396985f8514607936921b314ae726ec2052791fffec656bcf8cb69d, Trace: from 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0xb055f43cd396985f8514607936921b314ae726ec2052791fffec656bcf8cb69d, Trace: from 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e to 0x95e3d0fb07a33737e02fcfa0b14575f778e3391f, value 0.
TxHash: 0xb055f43cd396985f8514607936921b314ae726ec2052791fffec656bcf8cb69d, Trace: from 0x95e3d0fb07a33737e02fcfa0b14575f778e3391f to 0x883f5df5f8785d9c54b927b1362332b06b69bb56, value 0.
TxHash: 0xb055f43cd396985f8514607936921b314ae726ec2052791fffec656bcf8cb69d, Trace: from 0x95e3d0fb07a33737e02fcfa0b14575f778e3391f to 0x883f5df5f8785d9c54b927b1362332b06b69bb56, value 0.
TxHash: 0xb055f43cd396985f8514607936921b314ae726ec2052791fffec656bcf8cb69d, Trace: from 0x95e3d0fb07a33737e02fcfa0b14575f778e3391f to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0xb055f43cd396985f8514607936921b314ae726ec2052791fffec656bcf8cb69d, Trace: from 0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e to 0x883f5df5f8785d9c54b927b1362332b06b69bb56, value 0.
TxHash: 0x21fb0d311272b3182c4a486a5226aedccdfea57af8818d67a57e9c28ee4b0d71, Trace: from 0x1b5bbc00d336e42ce6dd79dda4b5ab056a614f4b to 0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad, value 500000000000000000.
TxHash: 0x21fb0d311272b3182c4a486a5226aedccdfea57af8818d67a57e9c28ee4b0d71, Trace: from 0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 500000000000000000.
TxHash: 0x21fb0d311272b3182c4a486a5226aedccdfea57af8818d67a57e9c28ee4b0d71, Trace: from 0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0x21fb0d311272b3182c4a486a5226aedccdfea57af8818d67a57e9c28ee4b0d71, Trace: from 0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad to 0x67f4c72a50f8df6487720261e188f2abe83f57d7, value 0.
TxHash: 0x21fb0d311272b3182c4a486a5226aedccdfea57af8818d67a57e9c28ee4b0d71, Trace: from 0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad to 0xa7fd8ff8f4cada298286d3006ee8f9c11e2ff84e, value 0.
TxHash: 0x21fb0d311272b3182c4a486a5226aedccdfea57af8818d67a57e9c28ee4b0d71, Trace: from 0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0x21fb0d311272b3182c4a486a5226aedccdfea57af8818d67a57e9c28ee4b0d71, Trace: from 0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad to 0xa7fd8ff8f4cada298286d3006ee8f9c11e2ff84e, value 0.
TxHash: 0x21fb0d311272b3182c4a486a5226aedccdfea57af8818d67a57e9c28ee4b0d71, Trace: from 0xa7fd8ff8f4cada298286d3006ee8f9c11e2ff84e to 0x67f4c72a50f8df6487720261e188f2abe83f57d7, value 0.
TxHash: 0x21fb0d311272b3182c4a486a5226aedccdfea57af8818d67a57e9c28ee4b0d71, Trace: from 0xa7fd8ff8f4cada298286d3006ee8f9c11e2ff84e to 0x67f4c72a50f8df6487720261e188f2abe83f57d7, value 0.
TxHash: 0x21fb0d311272b3182c4a486a5226aedccdfea57af8818d67a57e9c28ee4b0d71, Trace: from 0xa7fd8ff8f4cada298286d3006ee8f9c11e2ff84e to 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, value 0.
TxHash: 0x21fb0d311272b3182c4a486a5226aedccdfea57af8818d67a57e9c28ee4b0d71, Trace: from 0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad to 0x67f4c72a50f8df6487720261e188f2abe83f57d7, value 0.
TxHash: 0x828d35754b69f4a5f6abcd45408ecf86733bf436e94cfc006fa4047747a9be0a, Trace: from 0xfa69c0f63545562d6749b449f11c074a3d99a378 to 0x7a250d5630b4cf539739df2c5dacb4c659f2488d, value 0.
TxHash: 0x828d35754b69f4a5f6abcd45408ecf86733bf436e94cfc006fa4047747a9be0a, Trace: from 0x7a250d5630b4cf539739df2c5dacb4c659f2488d to 0x4f9fc4e0b79c1cbf16e68863ad5e9de6a94a346c, value 0.
TxHash: 0x828d35754b69f4a5f6abcd45408ecf86733bf436e94cfc006fa4047747a9be0a, Trace: from 0x7a250d5630b4cf539739df2c5dacb4c659f2488d to 0xdac17f958d2ee523a2206206994597c13d831ec7, value 0.
TxHash: 0x828d35754b69f4a5f6abcd45408ecf86733bf436e94cfc006fa4047747a9be0a, Trace: from 0x7a250d5630b4cf539739df2c5dacb4c659f2488d to 0x4f9fc4e0b79c1cbf16e68863ad5e9de6a94a346c, value 0.
TxHash: 0x828d35754b69f4a5f6abcd45408ecf86733bf436e94cfc006fa4047747a9be0a, Trace: from 0x4f9fc4e0b79c1cbf16e68863ad5e9de6a94a346c to 0x9ff58067bd8d239000010c154c6983a325df138e, value 0.
TxHash: 0x828d35754b69f4a5f6abcd45408ecf86733bf436e94cfc006fa4047747a9be0a, Trace: from 0x9ff58067bd8d239000010c154c6983a325df138e to 0x3e78f37b3902be9e0b3d370339294489023dc1f5, value 0.
TxHash: 0x828d35754b69f4a5f6abcd45408ecf86733bf436e94cfc006fa4047747a9be0a, Trace: from 0x3e78f37b3902be9e0b3d370339294489023dc1f5 to 0x668c1dae7b4e5e865b45b0111acc71f0dddede8a, value 0.
TxHash: 0x828d35754b69f4a5f6abcd45408ecf86733bf436e94cfc006fa4047747a9be0a, Trace: from 0x3e78f37b3902be9e0b3d370339294489023dc1f5 to 0x3e78f37b3902be9e0b3d370339294489023dc1f5, value 0.
TxHash: 0x828d35754b69f4a5f6abcd45408ecf86733bf436e94cfc006fa4047747a9be0a, Trace: from 0x3e78f37b3902be9e0b3d370339294489023dc1f5 to 0x668c1dae7b4e5e865b45b0111acc71f0dddede8a, value 0.
TxHash: 0x828d35754b69f4a5f6abcd45408ecf86733bf436e94cfc006fa4047747a9be0a, Trace: from 0x3e78f37b3902be9e0b3d370339294489023dc1f5 to 0xfa69c0f63545562d6749b449f11c074a3d99a378, value 0.
TxHash: 0x828d35754b69f4a5f6abcd45408ecf86733bf436e94cfc006fa4047747a9be0a, Trace: from 0x4f9fc4e0b79c1cbf16e68863ad5e9de6a94a346c to 0x9ff58067bd8d239000010c154c6983a325df138e, value 0.
TxHash: 0x828d35754b69f4a5f6abcd45408ecf86733bf436e94cfc006fa4047747a9be0a, Trace: from 0x4f9fc4e0b79c1cbf16e68863ad5e9de6a94a346c to 0xdac17f958d2ee523a2206206994597c13d831ec7, value 0.
{
    "0xa4606dfaedc482670ef4567187645b4052e189ab": -0.2,
    "0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e": -0.25,
    "0x6599ae06914f1f5ec0053d3f475348d40e608442": 0.25,
    "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2": 1.6916875,
    "0x77ad3a15b78101883af36ad4a875e17c86ac65d1": -4.72859578e-10,
    "0x00000000a991c429ee2ec6df19d40fe0c80088b8": 4.72859578e-10,
    "0xd92798abca9b68a122ffd7363541a19bee517786": -0.95,
    "0x881d40237659c251811cec9c364ef91dc08d300c": 0.0,
    "0x74de5d4fcbf63e00296fd95d33236b9794016631": -0.95,
    "0x7cdf68ce9a05413cbb76cb7f80eaf415a826e313": 0.95,
    "0x1111111254eeb25477b68fb85ed929f73a960582": 0.0,
    "0xf326e4de8f66a0bdc0970b79e0924e33c79f1915": 0.0,
    "0xd9db270c1b5e3bd161e8c8503c55ceabee709552": 0.0083125,
    "0x1d9262af4e61af885ef60ab76e35454b02b82a50": -1.2536e-14,
    "0x6f1cdbbb4d53d226cf4b917bf768b94acbab6168": 1.2536e-14,
    "0x1529282ea2d39c1a7a78608c0d0cab72a265196d": -0.05,
    "0x1b5bbc00d336e42ce6dd79dda4b5ab056a614f4b": -0.5,
    "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad": 0.0
}

On the docs, you can learn more about trace_transaction.

As you can see, it will display the change of ETH for each address. Notice that some values are so small that are not displayed correctly; you'll need to improve this.

1

I use debug_traceBlockByNumber and specify callTracer as the tracer, so I get every internal call of the block. And track values of these calls

Also you can trace separate transactions same way

P.S. tracing whole blocks is faster than every transaction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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