Alright but WTF is it actually
What Does “Parsing” Mean?
In the context of Openrep, parsing refers to the process of analyzing the raw on-chain data (transactions, logs/events) retrieved by the Indexer and transforming it into structured, contextualized information. This allows Openrep—and any consuming applications—to easily understand the intent and outcome of each transaction.
1. Classification
Identifying the Type of Action
Parsing logic determines the purpose of each on-chain interaction. For example:
Token Swap: A user exchanges Token A for Token B on a DEX (e.g., Uniswap).
Bridge Transaction: A user transfers assets from Chain X to Chain Y through a bridging protocol.
Liquidity Provision: A user deposits tokens into a liquidity pool.
Simple Transfer: A user moves tokens between two addresses (either EOAs or contracts).
By recognizing these categories, Openrep can draw more meaningful conclusions about a wallet’s on-chain behavior.
Filtering Out Non-Relevant Data
Many transactions may be irrelevant to a specific reputation context (e.g., internal system calls, contract creation). The Parser can skip over these so it focuses on the data that directly contributes to reputation metrics or analytics.
2. Data Extraction
Calldata (Transaction Data)
When a transaction interacts with a smart contract, the calldata holds clues about:
Which function was called.
What parameters were passed.
Using the contract’s ABI (Application Binary Interface), the Parser:
Identifies the function signature from the first few bytes of the calldata.
Decodes additional bytes to read parameters (e.g., tokens involved, amounts, recipient addresses).
For instance, a user calling a DEX function for a swap might have calldata indicating:
function swapExactTokensForTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
The Parser would decode how much of which token was being swapped, for which other token, and to which address.
Logs & Events
Smart contracts emit events (logs) during transaction execution. The Parser can:
Match a log’s event signature to known events (e.g.,
Transfer
on an ERC-20 contract).Decode the indexed parameters from the topics array and the unindexed data from the
data
field.Correlate multiple logs within the same transaction to understand the complete set of changes.
For instance, an ERC-20 Transfer
event typically has these pieces of information:
from: The sender of the tokens (indexed).
to: The receiver of the tokens (indexed).
value: The amount of tokens transferred (unindexed, stored in the
data
field).
3. Contextual Enrichment
Once the Parser classifies the transaction (e.g., “Swap” vs. “Bridge” vs. “Transfer”) and extracts essential details, it can add context, such as:
Protocol Identification: Which protocol the transaction interacted with (e.g., Uniswap, Balancer, or a specific bridge).
Token Metadata: Names, symbols, or decimals if required.
Timeframe Analysis: Using timestamps to group user actions or detect unusual activity patterns.
This extra layer of detail forms the backbone for Reputation Scoring since raw on-chain data is often too cryptic or fragmented to be directly useful.
4. Output & Storage
After classification and enrichment, the Parser:
Saves the enriched transaction data in the same (or a dedicated) database, appended with fields describing the parsed action.
Makes this annotated data accessible for reputation scoring or any other analytics.
For example, an annotated Swap record might look like this:
{
type: ACTION_ENUM.SINGLE_SWAP,
fromToken: "0x02D4f76656C2B4f58430e91f8ac74896c9281Cb9",
toToken: "0x4200000000000000000000000000000000000006",
fromAmount: "3972194774677555523824",
toAmount: "26889988447440968",
sender: "0x71B4Af0CC9459Ba7349077e668cb8b2A6b2b532F",
recipient: "0x71B4Af0CC9459Ba7349077e668cb8b2A6b2b532F"
}
5. Why Parsing Is Essential
Human-Readable Actions: Parsing turns raw hex data into clear and relevant actions.
Analytics & Reputation Scoring: Distinguishing transaction types helps Openrep accurately measure user activity.
Custom dApp Integrations: Protocols can define how to parse their specific events for more granular insights (e.g., identifying unique DeFi strategies or specialized bridging steps).
6. Contributing to Parsing Logic
Openrep’s parser repository is open source, allowing developers to:
Add New Parsers: Implement decoding logic for custom contracts or unusual event structures.
Extend Existing Parsers: Enhance the coverage of known DeFi or bridging protocols.
Maintain Up-to-Date Logic: Keep pace with protocol upgrades and new contract releases.
Last updated