Skip to content

Commit 02ad461

Browse files
authored
Merge pull request #4 from ccerv1/patch-1
add pyoso examples to metrics docs
2 parents bbabc4b + 6fc0a3f commit 02ad461

File tree

4 files changed

+100
-0
lines changed

4 files changed

+100
-0
lines changed

l2s/aa-by-chain.png

136 KB
Loading

l2s/aa-by-project.png

154 KB
Loading

l2s/how-to-create-your-own-4337-metrics.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,104 @@ The resulting data shows which Paymaster application has the biggest volume of c
9393

9494
![](how-to-create-your-own-4337-metrics-image-8.png)
9595

96+
## Using OSO's pyoso library for 4337 data analysis
97+
98+
For a more streamlined approach to analyzing Account Abstraction data, you can use OSO's pyoso library which provides direct access to curated 4337 datasets across all Superchain networks. This approach eliminates the need for BigQuery setup -- and lets you connect 4337 data with 100s of other public data models.
99+
100+
### Getting Started with pyoso
101+
102+
First, you'll need to [get an API key](https://docs.opensource.observer/docs/get-started/python) to access the data.
103+
104+
![](pyoso-api-key.png)
105+
106+
Then, install the pyoso library and set up your environment:
107+
108+
```bash
109+
pip install pyoso
110+
```
111+
112+
Initialize the client:
113+
114+
```python
115+
import pandas as pd
116+
from pyoso import Client
117+
118+
# Set up the OSO client
119+
OSO_API_KEY = "YOUR_API_KEY"
120+
client = Client(api_key=OSO_API_KEY)
121+
```
122+
123+
### Available 4337 Data Models
124+
125+
OSO hosts lighter weight "staging" versions of the same tables shared above:
126+
127+
- Enriched EntryPoint Traces (`stg_superchain__4337_traces`)
128+
- User Operation Logs (`stg_superchain__4337_userop_logs`)
129+
- OLI Address Labels (`stg_openlabelsinitiative__labels_decoded`)
130+
131+
### Example: Analyzing Paymaster Usage
132+
133+
Here's how to analyze paymaster usage across all Superchain networks:
134+
135+
```python
136+
# Get daily paymaster usage by project and chain
137+
df_paymaster_usage = client.to_pandas("""
138+
WITH paymasters AS (
139+
SELECT address
140+
FROM stg_openlabelsinitiative__labels_decoded
141+
WHERE tag_id = 'is_paymaster'
142+
),
143+
labeled_paymasters AS (
144+
SELECT
145+
address,
146+
MIN(tag_value) AS owner_project
147+
FROM stg_openlabelsinitiative__labels_decoded
148+
WHERE
149+
tag_id = 'owner_project'
150+
AND address IN (SELECT address FROM paymasters)
151+
GROUP BY 1
152+
)
153+
154+
SELECT
155+
DATE_TRUNC('DAY', block_timestamp) AS bucket_day,
156+
COALESCE(p.owner_project, 'unknown') AS owner_project,
157+
chain,
158+
COUNT(*) AS userops_count
159+
FROM stg_superchain__4337_userop_logs AS logs
160+
LEFT JOIN labeled_paymasters AS p ON logs.paymaster_address = p.address
161+
GROUP BY 1,2,3
162+
ORDER BY bucket_day DESC, userops_count DESC
163+
""")
164+
```
165+
166+
![](aa-by-project.png)
167+
168+
### Example: Chain-by-Chain Activity Analysis
169+
170+
Analyze Account Abstraction activity across different Superchain networks:
171+
172+
```python
173+
# Get total activity by chain
174+
df_chain_totals = client.to_pandas("""
175+
SELECT
176+
chain,
177+
COUNT(*) AS total_userops,
178+
COUNT(DISTINCT sender_address) AS unique_users,
179+
COUNT(DISTINCT paymaster_address) AS unique_paymasters,
180+
AVG(userop_gas_used) AS avg_gas_used,
181+
SUM(userop_gas_used * userop_gas_price) / 1e18 AS total_gas_cost_eth
182+
FROM stg_superchain__4337_userop_logs
183+
WHERE paymaster_address != '0x0000000000000000000000000000000000000000'
184+
GROUP BY chain
185+
ORDER BY total_userops DESC
186+
""")
187+
```
188+
189+
![](aa-by-chain.png)
190+
191+
For a longer tutorial on Account Abstraction analysis using pyoso, check out the [Monitor Account Abstraction Adoption tutorial](https://docs.opensource.observer/docs/tutorials/account-abstraction/) which covers user operations, paymaster analysis, and cross-chain activity patterns.
192+
193+
194+
---
195+
96196
Thanks for reading and feel free to outreach to Superchain 4337 Team in case any questions or ideas arise!

l2s/pyoso-api-key.png

195 KB
Loading

0 commit comments

Comments
 (0)