Skip to content

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.

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, or null when the node has seen no blob with that hash.

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. null when the node knows no blob transaction with that hash, which is also the answer for a transaction that carried no blob.
  • The two hashes are not interchangeable. getBlobByHash given a transaction hash and getBlobsByTransactionHash given a versioned hash both return null.
  • Sending a blob transaction. Eth.sendTransaction takes the blobs with their commitments and proofs in the blobs, commitments and proofs fields of the request. ethect computes none of the three: they come from a KZG library.