Sub topic 1
What a Public Ledger Does and Does Not Reveal
Prerequisites
This chapter assumes you know what a blockchain, a wallet address, and a transaction are. You should understand the high-level difference between Bitcoin and Ethereum, and you should be able to read basic Python: lists, dictionaries, and functions.
What a Public Ledger Reveals
A public ledger records every transfer, and anyone can read it. You can see amounts, timestamps, and the addresses involved. The ledger does not record who controls an address. A label such as "exchange" is an inference that analysts make from patterns. It is not stored on chain.
UTXO and Account Models
Bitcoin uses the UTXO model. A UTXO (unspent transaction output) is a coin-like amount that a past transaction sent to an address and that nobody has spent yet. A transaction consumes whole UTXOs and creates new ones, so tracking a payment means following outputs through inputs.
Ethereum uses the account model. Each address holds a balance that the network updates directly.
| Model | How balance is stored | Effect on tracking |
|---|---|---|
| UTXO (Bitcoin) | Set of unspent outputs | Follow outputs through inputs; change outputs add noise |
| Account (Ethereum) | One balance per address | Read balances directly; tokens live in contracts |
Tracking Token Transfers Through Event Logs
ERC-20 tokens emit a Transfer event on each transfer. The first topic is the keccak-256 hash of Transfer(address,address,uint256). The following request fetches those events from a token contract over a small block range:
{
"jsonrpc": "2.0",
"id": 1,
"method": "eth_getLogs",
"params": [
{
"fromBlock": "0x10d4f00",
"toBlock": "0x10d4f0a",
"address": "<TOKEN_CONTRACT_ADDRESS>",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
]
}
]
}> Note: Some tokens emit non-standard events, so a log filter can miss transfers.
Where the Data Comes From
- Full node: Gives complete, exact data. You run the software yourself, and storage is costly.
- Block explorer: Quick to query and useful for spot checks. Usage limits apply.
- Analytics API: Provides pre-processed and labeled data. You depend on the provider's labels and terms.
Grouping Addresses Into Entities
The common-input heuristic assumes that addresses spent together in one Bitcoin transaction have the same owner. The function below merges such addresses with a union-find structure.
def cluster_by_common_input(transactions):
parent = {}
def find(a):
parent.setdefault(a, a)
while parent[a] != a:
parent[a] = parent[parent[a]]
a = parent[a]
return a
def union(a, b):
ra, rb = find(a), find(b)
if ra != rb:
parent[rb] = ra
for inputs in transactions:
for addr in inputs:
find(addr)
for addr in inputs[1:]:
union(inputs[0], addr)
return {addr: find(addr) for addr in list(parent)}
txs = [["A", "B"], ["C", "D"], ["B", "C"]]
print(cluster_by_common_input(txs))> Warning: CoinJoin transactions combine inputs from unrelated owners, so this heuristic wrongly merges their addresses.
Exercise:
Exercise
For the transactions [["A", "B"], ["C", "D"], ["B", "C"]], which addresses end up in the same cluster?
Show answer
All four (A, B, C, D) share one cluster. The first transaction joins A and B, the second joins C and D, and the third joins B's cluster with C's cluster.