Ethereum Transaction Knowledge Graph
- TKG is a multi-relational directed graph constructed from on-chain Ethereum transactions that encodes fund-flow and curated behavioral features.
- The methodology uses GNN-based message passing with masked co-attention to fuse expert features with transformer embeddings for robust link prediction.
- Joint pre-training and expert feature integration yield significant improvements in phishing detection and account de-anonymization tasks.
Searching arXiv for the cited papers to ground the article in current literature. A Transaction Knowledge Graph (TKG), in the formulation introduced in "KGBERT4Eth" (Jia et al., 4 Sep 2025), is a multi-relational directed graph over Ethereum addresses and transaction relations, designed to encode fund-flow structure together with expert-curated behavioral features. Within that framework, the TKG is one of two jointly trained components of a feature-complete encoder, the other being a Transaction LLM (TLM) operating over conceptualized transaction records. The TKG supplies structured representations of transaction modalities, latent transaction relationships, and node-level financial, temporal, and network-structural signals, and is integrated with the transformer stream through masked co-attention during pre-training (Jia et al., 4 Sep 2025).
1. Formal definition and representational scope
In KGBERT4Eth, the TKG is defined as a multi-relational directed graph
where is the set of entities, identified with Ethereum addresses, and is the set of labeled edges or triples (Jia et al., 4 Sep 2025). The node set comprises two account types: Externally Owned Accounts (EOA) and Contract Accounts (CA). The relation vocabulary contains two high-level transaction modalities: external_tx, denoting a direct Ether transfer from one address to another, and contract_tx, denoting a transfer or call that routes through a smart contract. Semantically, a triple means that entity engages in a transaction of type with entity (Jia et al., 4 Sep 2025).
Each node is initialized with a real-valued feature vector . These attributes span three categories. The first is financial statistics, including examples such as max/min/avg incoming/outgoing amounts, balance, and in/out ratio. The second is temporal activity, including account lifetime, active days, and short/long-term transfer frequencies. The third is network-structural metrics, including degree, betweenness, closeness, Katz and eigenvector centralities, and clustering coefficient (Jia et al., 4 Sep 2025).
This schema makes the TKG explicitly heterogeneous at both the edge and feature levels. A plausible implication is that the graph is intended to preserve distinctions that would be collapsed in purely sequence-based or purely embedding-based fraud detectors. In the paper’s terminology, this is part of the broader attempt to combine structured fund-flow patterns with human-curated feature insights (Jia et al., 4 Sep 2025).
2. Construction from on-chain transaction records
The graph construction process begins with node extraction from raw on-chain data. All distinct addresses appearing in the from, to, or contractAddress fields of transactions are collected into 0. Each address is then labeled as EOA or CA depending on whether it ever appears as a contractAddress (Jia et al., 4 Sep 2025).
Edge extraction is transaction-wise. For each transaction record 1, let 2 and 3. If 4 is empty, the graph adds the triple 5. Otherwise, when the record corresponds to a contract invocation, it adds 6 (Jia et al., 4 Sep 2025). The resulting edge set therefore distinguishes direct Ether transfers from contract-mediated interactions using only two relation types.
Feature computation proceeds over a historical window. Per-node statistics such as total numbers of incoming and outgoing transfers and transferred amounts are computed. Temporal indicators are then derived, with lifetime defined as
7
and active days defined as the number of distinct days. A one-hop transaction graph is constructed to compute centrality and clustering metrics. These signals are concatenated to form the initial node embedding 8 (Jia et al., 4 Sep 2025).
The paper’s pseudocode summarizes this pipeline as follows: all unique addresses are inserted into 9; expert features 0 are computed for each node; an MLP maps these to initial node states 1; and the edge set 2 is populated by iterating over transactions and assigning either external_tx or contract_tx according to whether contractAddress is empty (Jia et al., 4 Sep 2025).
3. Embedding methodology and transaction link prediction
The TKG encoder is GNN-based. At layer 3, node embeddings 4 are updated by attention-weighted neighborhood aggregation:
5
6
where
7
and
8
Here 9 is the learned embedding of the relation label on edge 0, 1 are learnable linear maps, and 2 is a nonlinearity. The formulation also permits multi-head variants through repetition with separate parameter sets (Jia et al., 4 Sep 2025).
Pre-training on the graph uses a Transaction Link Prediction (TLP) objective. Let 3 be the set of positive triples 4, and let 5 be a set of negative, corrupted triples. Using a scoring function 6, with examples including TransE, RotatE, and DistMult, the loss is defined as
7
where 8 is a margin and 9 is the sigmoid. The paper also gives a simplified notation:
0
For graph pre-training in the full model, RotatE scoring is used by default (Jia et al., 4 Sep 2025).
This embedding design makes the TKG not merely a static store of engineered features, but a learnable relational encoder whose node representations are updated by message passing and supervised by link prediction. This suggests that latent transaction regularities are expected to emerge from both topological context and explicit relation labels.
4. Coupling with the transformer through mask-invariant attention synergy
The TKG is not trained in isolation. In KGBERT4Eth it is jointly optimized with a transformer-based TLM through a mask-invariant attention synergy module. At layer 1, the transformer provides semantic embeddings
2
while the graph encoder provides entity embeddings
3
The co-attention update from semantics to graph restricts cross-attention so that only the 4 position can attend to 5, implemented by a visibility mask
6
The attention weights are
7
and the attended representation is
8
In practice, only 9 receives non-masked attention; all other tokens remain unchanged (Jia et al., 4 Sep 2025).
The update is symmetric in the reverse direction. Treating 0 as queries, graph embeddings are allowed to attend only to 1:
2
3
The fused outputs are integrated by residual feed-forward updates and layer normalization:
4
with each 5 updated analogously (Jia et al., 4 Sep 2025).
A notable design decision is that no extra coordination loss is introduced; the two streams influence each other purely through this masked co-attention. Within the paper’s framework, the TKG therefore contributes to representation fusion indirectly through layerwise interaction rather than through a separate alignment objective.
5. Joint pre-training objectives, algorithmic workflow, and operational scale
The transformer stream is pre-trained with Biased Masked Prediction (BMP). For each account’s transaction text 6, BM25 scores are computed per token. A token 7 is masked if
8
with 9, and standard MLM cross-entropy is applied only over selected tokens:
0
The graph stream is trained with the TLP objective described above, and the combined loss is
1
The paper states that the biased masking task is designed to emphasize rare anomalous transactions by focusing on statistical outliers (Jia et al., 4 Sep 2025).
The joint pre-training loop alternates between transformer forward propagation over masked transaction text, GNN propagation over sampled account subgraphs, application of the mask-invariant attention synergy module, and accumulation of 2 and 3. Parameters of both encoders are then updated jointly by back-propagation. In the provided pseudocode, a batch of accounts 4 and their subgraphs 5 are sampled; token embeddings are processed through transformer layers; node embeddings are processed through GNN layers; the MiAS module fuses the streams; and losses are accumulated before an optimizer step (Jia et al., 4 Sep 2025).
The operational scale reported for pre-training is a corpus of 3.25 M transactions, yielding approximately 500 k nodes and 1 M edges. The transformer backbone is BERT-base (12 layers, 6) with maximum sequence length 7. The mask threshold is 8 using the BM25L variant. The number of GNN layers is not explicitly fixed, though 2–3 are described as typical experimentally. At fine-tuning time, subgraph sampling uses a 2-hop neighborhood with 9 nodes. Optimization uses the Adam optimizer (standard BERT settings) with learning rate approximately 0 and total steps approximately 100 k (Jia et al., 4 Sep 2025).
6. Role in Ethereum fraud detection and relation to broader TKG literature
Within KGBERT4Eth, the TKG is one component of a feature-complete encoder for multi-task Ethereum fraud detection. The paper states that existing detection mechanisms bifurcate into three technical strands: expert-defined features, graph embeddings, and sequential transaction patterns, and argues that the absence of cross-paradigm integration mechanisms forces practitioners to trade off among sequential context awareness, structured fund-flow patterns, and human-curated feature insights. The TKG is introduced specifically to incorporate expert-curated domain knowledge into graph node embeddings so as to capture fund-flow patterns and human-curated feature insights, while the TLM captures contextual semantic representations from conceptualized transaction records (Jia et al., 4 Sep 2025).
Empirically, KGBERT4Eth is reported to significantly outperform state-of-the-art baselines in both phishing account detection and de-anonymization tasks, with absolute F1-score improvements of 8–16% on three phishing detection benchmarks and 6–26% on four de-anonymization datasets (Jia et al., 4 Sep 2025). Because the model is defined as jointly optimizing the TLM and TKG pre-training objectives, these improvements are attributed at the system level rather than to the graph component alone.
A common source of terminological ambiguity is that TKG is also widely used to denote Temporal Knowledge Graph in the knowledge graph forecasting and completion literature. In that literature, a TKG is a set of timestamped quadruples 1 or, equivalently, a sequence of graph snapshots 2, and typical tasks involve forecasting future facts or completing missing entities under temporal constraints (Lee et al., 2023). T-GAP, for example, defines a Temporal Knowledge Graph as a set of time-annotated facts 3 and studies query answering of the form 4 באמצעות displacement-aware temporal GNN encoding and path-based attention flow (Jung et al., 2020). HyperVC likewise treats a TKG as a sequence of graph snapshots and models chronological hierarchies autoregressively in hyperbolic space with variable curvature (Sohn et al., 2022).
This dual usage does not indicate conceptual identity between the two notions. In KGBERT4Eth, the TKG is a transaction-centric, feature-augmented relational graph over Ethereum accounts; in the temporal KG literature, the graph is defined primarily through timestamped facts and forecasting or completion objectives. A plausible implication is that the acronym alone is insufficiently specific in cross-domain discussion, especially when blockchain transaction graphs and temporal knowledge graphs are both under consideration.