Sub topic 4
Active addresses: definition and computation
This chapter assumes you know what a blockchain transaction is and can read short Python programs. It also assumes you are comfortable with sets and with grouping data by a time bucket. Earlier chapters covered account-based and UTXO ledgers, and why an address is not a person. This chapter turns that background into one concrete metric, the active address count, and shows how to compute it.
What "active address" means
An active address is an address that took part in at least one qualifying event during a time window. Each part of that sentence is a choice you must make:
- Event type: a transfer of the native coin, a token transfer, a smart contract call, or any of these.
- Role: the address appears as sender, as receiver, or as either.
- Window: one UTC day, one week, one month, or a rolling window.
- Filters: a minimum value, a status such as "successful transactions only", and whether contract addresses count.
No single standard exists, so two data providers can report different "daily active addresses" for the same chain on the same day. Both can be correct under their own definitions. When you compare numbers, compare definitions first.
The most common definition is this one:
> The number of distinct addresses that appear as sender or receiver in at least one successful transfer during a UTC calendar day.
The word distinct matters. If one address sends 500 transactions in a day, it adds 1 to the count. That is what separates active addresses from transaction counts, which a later chapter covers.
The computation
The computation has three steps:
- Convert each transfer's timestamp to a day.
- Add the sender and the receiver to a set for that day.
- Count the size of each set.
A set removes duplicates automatically, so each address is counted once per day.
from collections import defaultdict
from datetime import datetime, timezone
transfers = [
{"ts": 1700000000, "from": "0xa", "to": "0xb", "value": 5},
{"ts": 1700003600, "from": "0xb", "to": "0xc", "value": 2},
{"ts": 1700090000, "from": "0xa", "to": "0xc", "value": 1},
]
def daily_active_addresses(transfers):
days = defaultdict(set)
for t in transfers:
day = datetime.fromtimestamp(t["ts"], tz=timezone.utc).date()
days[day].add(t["from"])
days[day].add(t["to"])
return {day: len(addrs) for day, addrs in sorted(days.items())}
print(daily_active_addresses(transfers))The output is {datetime.date(2023, 11, 14): 3, datetime.date(2023, 11, 15): 2}. On 14 November, addresses 0xa, 0xb and 0xc all took part, and 0xb appeared twice but counts once. On 15 November only 0xa and 0xc took part.
Two details in the code are easy to get wrong:
tz=timezone.utcis required. Without it,fromtimestampuses the machine's local time zone, and the same data gives different daily counts on different computers.- The sets live only for the length of the loop. On a real chain with millions of transfers per day, storing every address in memory may not be practical. Large pipelines do this step in a database with
COUNT(DISTINCT ...)or use an approximate counter such as HyperLogLog. Approximate counters trade a small error, usually around one or two percent, for fixed memory.
Choosing the role: sender, receiver, or both
The role you count changes what the metric means.
| Role counted | What it measures | Weakness |
|---|---|---|
| Sender only | Addresses that signed a transaction, so someone with a key chose to act | Misses users who only received funds |
| Receiver only | Addresses that were credited | Anyone can send dust to thousands of addresses and inflate it |
| Sender or receiver | Any participation | Inherits the weaknesses of both |
Sender-only counts are harder to fake cheaply, because each sender must hold funds for fees. Receiver counts are easy to inflate. The sender-only count is therefore the stricter measure of deliberate activity. Many analysts report both, and a large gap between them is itself a signal worth investigating.
The function below makes the role and a minimum value into parameters:
from collections import defaultdict
from datetime import datetime, timezone
def active_by_day(transfers, role="both", min_value=0):
days = defaultdict(set)
for t in transfers:
if t["value"] < min_value:
continue
day = datetime.fromtimestamp(t["ts"], tz=timezone.utc).date()
if role in ("both", "sender"):
days[day].add(t["from"])
if role in ("both", "receiver"):
days[day].add(t["to"])
return {day: len(addrs) for day, addrs in sorted(days.items())}
transfers = [
{"ts": 1700000000, "from": "0xa", "to": "0xb", "value": 5},
{"ts": 1700003600, "from": "0xb", "to": "0xc", "value": 2},
{"ts": 1700090000, "from": "0xa", "to": "0xc", "value": 1},
]
print(active_by_day(transfers, role="sender"))
print(active_by_day(transfers, role="receiver"))
print(active_by_day(transfers, min_value=2))Run on the sample data, the sender count is 2 on the first day and 1 on the second. The receiver count is also 2 and 1. With min_value=2, the third transfer (value 1) is dropped, so the second day disappears from the output entirely. Note that a day with no qualifying events is absent, not zero. If you plot or average the results, fill those gaps explicitly, or your averages will skip the quietest days.
How the ledger model changes the inputs
The code above assumes each transfer has one sender and one receiver. Real ledgers are messier, and the way they are messy depends on the ledger model.
Account-based chains
On an account-based chain such as Ethereum, a transaction has one sender. The receiver can be an ordinary account or a contract. Two extra complications follow:
- Token transfers are events, not transactions. An ERC-20 transfer is recorded as a
Transferlog emitted by the token contract. To count addresses that moved a token, you read these logs. The transaction's owntofield is the token contract, which is not the real counterparty. - Internal calls. A contract can send native coin to other addresses during execution. These do not appear as top-level transactions. They appear in execution traces, which many data sources omit by default.
If you count only top-level transactions, you will see contracts as receivers and miss many real receivers. Decide whether contracts belong in the count. A popular exchange or decentralized application contract can appear in thousands of transfers a day, and it is one address.
UTXO chains
On a UTXO chain such as Bitcoin, a transaction consumes several inputs and creates several outputs. There is no single sender and no single receiver. The usual approach is:
- Treat every distinct address in the inputs as a sender.
- Treat every distinct address in the outputs as a receiver.
The main distortion is change outputs. If you spend a 1.0 coin output to pay 0.3, the wallet typically sends 0.7 back to a fresh address it controls. Counting that address as an active receiver adds an address that belongs to the same person who just sent the payment. On UTXO chains, receiver-based counts therefore overstate the number of independent participants more than they do on account-based chains. This is one reason UTXO analysts lean on sender counts or on entity clustering.
Windows: daily, weekly, and rolling
A daily count answers "how many distinct addresses acted today". A weekly count answers a different question, and it is not the sum of seven daily counts. Addresses active on several days would be counted several times in the sum.
The function below computes a rolling window of window_days days that ends on each day:
from collections import defaultdict
from datetime import datetime, timedelta, timezone
def rolling_active(transfers, window_days):
days = defaultdict(set)
for t in transfers:
day = datetime.fromtimestamp(t["ts"], tz=timezone.utc).date()
days[day].add(t["from"])
days[day].add(t["to"])
result = {}
for day in sorted(days):
union = set()
for k in range(window_days):
union |= days.get(day - timedelta(days=k), set())
result[day] = len(union)
return result
transfers = [
{"ts": 1700000000, "from": "0xa", "to": "0xb", "value": 5},
{"ts": 1700003600, "from": "0xb", "to": "0xc", "value": 2},
{"ts": 1700090000, "from": "0xa", "to": "0xc", "value": 1},
]
print(rolling_active(transfers, 2))On 15 November the two-day window covers both days. The union of {a, c} and {a, b, c} has 3 addresses, while the sum of the daily counts would be 5. This ratio is useful. If the weekly count is only a little larger than the daily count, the same addresses return every day. If it is many times larger, most addresses appear once and leave.
Window choice affects comparisons across chains. A chain with daily-active-users in the millions and one in the thousands can only be compared meaningfully if both use the same window and the same time zone.
A quick check on any result
Before trusting a daily active address series, run through these checks:
- Plot the series and look for sudden jumps. A jump of several times the usual level on one day often signals a dust campaign or an airdrop, not adoption.
- Compare sender-only against receiver-only counts. A large receiver excess suggests mass distribution of tiny amounts.
- Check the share of the day's active addresses that made exactly one transfer. A high and rising share suggests disposable addresses.
- Re-run the count with a small minimum value. If the result falls sharply, many of the counted events were dust.
- Confirm the time zone and the day boundary. A series with an off-by-one-day shift in its timestamps will still look plausible.
Common mistakes
- Using local time. Always convert to UTC explicitly.
- Summing daily counts to get a weekly count. Use a union of the sets instead.
- Counting token contracts as receivers of token transfers because the transaction's
tofield was used instead of theTransferlog. - Ignoring failed transactions. On account-based chains, failed transactions still appear in the ledger and still cost fees. Decide whether they count. Most definitions exclude them.
- Treating missing days as zero in averages or, the opposite, leaving gaps out of a time axis.
Exercise
A provider reports 400,000 daily active addresses for a chain, counting sender or receiver. A second provider reports 150,000 for the same day, counting senders only. The two figures use the same data. Give two reasons the numbers can both be correct, and name one check you would run to learn more.
Show answer
The first figure includes receivers and the second does not. Receivers include addresses that never signed anything, such as those credited by airdrops, dust sends, or change outputs, so the first count is naturally larger. The two providers may also differ on contracts, failed transactions, or minimum value. A useful check is to compute the sender-only and receiver-only counts yourself from the same transfers and compare. A large receiver excess points to mass distribution of small amounts. You can also re-run the count with a small minimum value to see how much of the gap is dust.
Exercise
In the rollingactive example with windowdays=2, the daily counts are 3 and 2, but the 15 November rolling count is 3 and not 5. Explain why, and say what a large gap between the rolling weekly count and seven times the average daily count would tell you.
Show answer
The rolling count takes the union of the address sets for the two days, and addresses a and c appear on both days, so each is counted once. The sum 3 + 2 = 5 counts those two addresses twice. If the weekly count is far below seven times the average daily count, many of the same addresses return on most days, which indicates a stable, repeat-using population. If the weekly count is close to seven times the daily average, most addresses appear on only one day, which is typical of disposable addresses or one-off events.