Skip to content

Commit 0584153

Browse files
feat: create a blobdecoder tool (#2628)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. NOTE: PR titles should follow semantic commits: https://www.conventionalcommits.org/en/v1.0.0/ --> ## Overview I was debugging and whipped up a blob decoder, we can throw it up somewhere if we want. I found it useful, someone else may as well --------- Co-authored-by: Julien Robert <[email protected]>
1 parent 6e25408 commit 0584153

File tree

3 files changed

+1311
-0
lines changed

3 files changed

+1311
-0
lines changed

docs/guides/da/blob-decoder.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# Blob Decoder Tool
2+
3+
The blob decoder is a utility tool for decoding and inspecting blobs from Celestia (DA) layers. It provides both a web interface and API for decoding blob data into human-readable format.
4+
5+
## Overview
6+
7+
The blob decoder helps developers and operators inspect the contents of blobs submitted to DA layers. It can decode:
8+
- Raw blob data (hex or base64 encoded)
9+
- Block data structures
10+
- Transaction payloads
11+
- Protobuf-encoded messages
12+
13+
## Usage
14+
15+
### Starting the Server
16+
17+
```bash
18+
# Run with default port (8080)
19+
go run tools/blob-decoder/main.go
20+
```
21+
22+
The server will start and display:
23+
- Web interface URL: `http://localhost:8080`
24+
- API endpoint: `http://localhost:8080/api/decode`
25+
26+
### Web Interface
27+
28+
1. Open your browser to `http://localhost:8080`
29+
2. Paste your blob data in the input field
30+
3. Select the encoding format (hex or base64)
31+
4. Click "Decode" to see the parsed output
32+
33+
### API Usage
34+
35+
The decoder provides a REST API for programmatic access:
36+
37+
```bash
38+
# Decode hex-encoded blob
39+
curl -X POST http://localhost:8080/api/decode \
40+
-H "Content-Type: application/json" \
41+
-d '{
42+
"data": "0x1234abcd...",
43+
"encoding": "hex"
44+
}'
45+
46+
# Decode base64-encoded blob
47+
curl -X POST http://localhost:8080/api/decode \
48+
-H "Content-Type: application/json" \
49+
-d '{
50+
"data": "SGVsbG8gV29ybGQ=",
51+
"encoding": "base64"
52+
}'
53+
```
54+
55+
#### API Request Format
56+
57+
```json
58+
{
59+
"data": "string", // The encoded blob data
60+
"encoding": "string" // Either "hex" or "base64"
61+
}
62+
```
63+
64+
#### API Response Format
65+
66+
```json
67+
{
68+
"success": true,
69+
"decoded": {
70+
// Decoded data structure
71+
},
72+
"error": "string" // Only present if success is false
73+
}
74+
```
75+
76+
## Supported Data Types
77+
78+
### Block Data
79+
80+
The decoder can parse ev-node block structures:
81+
- Block height
82+
- Timestamp
83+
- Parent hash
84+
- Transaction list
85+
- Validator information
86+
- Data commitments
87+
88+
### Transaction Data
89+
90+
Decodes individual transactions including:
91+
- Transaction type
92+
- Sender/receiver addresses
93+
- Value/amount
94+
- Gas parameters
95+
- Payload data
96+
97+
### Protobuf Messages
98+
99+
Automatically detects and decodes protobuf-encoded messages used in ev-node:
100+
- Block headers
101+
- Transaction batches
102+
- State updates
103+
- DA commitments
104+
105+
## Examples
106+
107+
### Decoding a Block Blob
108+
109+
```bash
110+
# Example block blob (hex encoded)
111+
curl -X POST http://localhost:8080/api/decode \
112+
-H "Content-Type: application/json" \
113+
-d '{
114+
"data": "0a2408011220...",
115+
"encoding": "hex"
116+
}'
117+
```
118+
119+
Response:
120+
```json
121+
{
122+
"success": true,
123+
"decoded": {
124+
"height": 100,
125+
"timestamp": "2024-01-15T10:30:00Z",
126+
"parentHash": "0xabc123...",
127+
"transactions": [
128+
{
129+
"type": "transfer",
130+
"from": "0x123...",
131+
"to": "0x456...",
132+
"value": "1000000000000000000"
133+
}
134+
]
135+
}
136+
}
137+
```
138+
139+
### Decoding DA Commitment
140+
141+
```bash
142+
curl -X POST http://localhost:8080/api/decode \
143+
-H "Content-Type: application/json" \
144+
-d '{
145+
"data": "eyJjb21taXRtZW50IjogIi4uLiJ9",
146+
"encoding": "base64"
147+
}'
148+
```
149+
150+
### Celestia
151+
152+
For Celestia blobs, you can decode namespace data and payment information from [celenium](https://celenium.io/namespaces).

0 commit comments

Comments
 (0)