Get versioned blob hash by index from EIP-4844 blob transaction
This page is a placeholder. All examples on this page are currently AI-generated and are not correct. This documentation will be completed in the future with accurate, tested examples.
Overview
Opcode:0x49Introduced: Cancun (EIP-4844)BLOBHASH retrieves a versioned blob hash from the current transaction’s blob list by index. This enables proto-danksharding support, allowing contracts to verify blob commitments for Layer 2 data availability.
Specification
Stack Input:
index (u256)
Stack Output:
versioned_hash (or 0 if out of bounds)
Gas Cost: 3 (GasFastestStep)Operation:
if index < len(tx.blob_versioned_hashes): stack.push(tx.blob_versioned_hashes[index])else: stack.push(0)
Hardfork: Available from Cancun onwards (EIP-4844)
Behavior
BLOBHASH retrieves a versioned hash from the transaction’s blob array:
Blobs are only available for a limited time (~18 days on Ethereum):
contract BlobExpiry { struct BlobReference { bytes32 hash; uint256 expiryBlock; } uint256 constant BLOB_RETENTION_BLOCKS = 4096 * 32; // ~18 days function storeBlob(uint256 index) external { bytes32 hash = blobhash(index); require(hash != bytes32(0), "No blob"); // Blob data expires after retention period uint256 expiry = block.number + BLOB_RETENTION_BLOCKS; // Store hash, but blob data won't be retrievable after expiry }}
Index Validation
Always check for zero return (out of bounds):
contract SafeBlobAccess { function safeGetBlob(uint256 index) external view returns (bytes32) { bytes32 hash = blobhash(index); require(hash != bytes32(0), "Blob not found"); return hash; } // UNSAFE: Doesn't check zero function unsafeGetBlob(uint256 index) external view returns (bytes32) { return blobhash(index); // Could be 0! }}
Commitment vs Data
BLOBHASH returns commitment hash, not actual blob data:
contract BlobMisunderstanding { // WRONG: Cannot access blob data on-chain function getBlobData(uint256 index) external view returns (bytes memory) { bytes32 hash = blobhash(index); // hash is just a commitment, not the data itself! // Actual blob data is NOT available to EVM } // CORRECT: Store commitment for off-chain verification function storeCommitment(uint256 index) external returns (bytes32) { bytes32 commitment = blobhash(index); // Off-chain: fetch blob from beacon node // On-chain: verify commitment matches return commitment; }}