Try it Live
Run Blob examples in the interactive playground
Encoding Format
Blobs created withfromData() use this format:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Extract original data from blob (reads length prefix)
fromData() use this format:
┌─────────────────┬──────────────┬─────────────┐
│ Length (8 B) │ Data (N B) │ Padding │
├─────────────────┼──────────────┼─────────────┤
│ Little-endian │ Original │ Zero bytes │
│ uint64 │ data │ │
└─────────────────┴──────────────┴─────────────┘
Bytes 0-7 Bytes 8-N Bytes N+1-131071
Total: 131,072 bytes (Blob.SIZE)
import { Blob } from 'tevm';
const blob = Blob.fromData(new TextEncoder().encode("test"));
// Manual extraction (equivalent to toData())
const view = new DataView(blob.buffer, blob.byteOffset);
const length = Number(view.getBigUint64(0, true)); // Little-endian
const data = blob.slice(8, 8 + length);
console.log(length); // 4
console.log(new TextDecoder().decode(data)); // "test"
Was this page helpful?
