Blobs
The two methods that return the blobs of EIP-4844 transactions a test node has seen: one blob by its versioned hash, or every blob of a transaction.
| Method | JSON-RPC | Returns | Description |
|---|---|---|---|
getBlobByHash |
anvil_getBlobByHash |
Hex | null |
A blob the node has seen, by its versioned hash. |
getBlobsByTransactionHash |
anvil_getBlobsByTransactionHash |
Hex[] | null |
The blobs a transaction carried. |
Each takes one Hash and returns an
Effect<…, Method.Error, Transport>. A blob is not part
of a block: a transaction only carries the versioned hashes of its blobs, and these methods
give the data back.
getBlobByHash
Section titled “getBlobByHash”Returns a blob by its versioned hash, as listed in the blobVersionedHashes of an EIP-4844
transaction.
import { Effect } from "effect";import { Anvil, Eth } from "@ethect/core/rpc";
const firstBlob = (hash: `0x${string}`) => Effect.gen(function* () { const transaction = yield* Eth.getTransactionByHash(hash); if (transaction?.type !== "eip4844") return null; const [versionedHash] = transaction.blobVersionedHashes; if (versionedHash === undefined) return null; return yield* Anvil.getBlobByHash(versionedHash); });- JSON-RPC:
anvil_getBlobByHash - Parameters:
versionedHash(Hash). - Returns:
Hex | null. The blob as hex, ornullwhen the node has seen no blob with that hash.
getBlobsByTransactionHash
Section titled “getBlobsByTransactionHash”Returns the blobs a transaction carried.
import { Effect } from "effect";import { Hex } from "@ethect/core";import { Anvil } from "@ethect/core/rpc";
const blobSizes = (hash: `0x${string}`) => Anvil.getBlobsByTransactionHash(hash).pipe( Effect.map((blobs) => (blobs === null ? [] : blobs.map(Hex.size))), );- JSON-RPC:
anvil_getBlobsByTransactionHash - Parameters:
hash(Hash), the hash of the transaction. - Returns:
ReadonlyArray<Hex> | null.nullwhen the node knows no blob transaction with that hash, which is also the answer for a transaction that carried no blob.
Behavior
Section titled “Behavior”- The two hashes are not interchangeable.
getBlobByHashgiven a transaction hash andgetBlobsByTransactionHashgiven a versioned hash both returnnull. - Sending a blob transaction.
Eth.sendTransactiontakes the blobs with their commitments and proofs in theblobs,commitmentsandproofsfields of the request. ethect computes none of the three: they come from a KZG library.