Blob Transactions (EIP-4844)
This guide demonstrates how to generate, send, fetch, and verify a Blob Transaction when integrating rollup data into the IoTeX blockchain using EIP-4844 Blob Transactions. These steps ensure scalability and data integrity for rollup-based systems.
Overview
EIP-4844 introduces a new transaction type called Blob Transactions to improve scalability by enabling the temporary storage of large amounts of data outside of a blockchain's execution layer.
Here are key points about the Blob transaction:
Blob transactions contain large amounts of data that are not directly stored in the Blockchain's execution layer (i.e., they are not part of the state or permanent history).
This data is ephemeral and is retained only for a short period (e.g., 20 days) to facilitate rollup proofs.
It is designed to significantly reduce the cost of rollup solutions (Layer 2 scaling technologies) by allowing them to post off-chain data (proofs, commitments) to a Blockchain more efficiently.
This off-chain data is essential for rollups to verify transactions but doesn't need to persist in the Blockchain's state.
Gas-efficient: Lower costs for rollups to post data compared to traditional calldata.
EIP-4844 reduces costs for Layer 2 solutions, setting the stage for Ethereum’s future scalability improvements, such as danksharding.
Blob Data Structure
The blob data structure in EIP-4844 is as follows:
// BlobTxSidecar contains the blobs of a blob transaction.
type BlobTxSidecar struct {
Blobs []kzg4844.Blob // Blob is 128kB bytes array
Commitments []kzg4844.Commitment // Commitment is 48-bytes
Proofs []kzg4844.Proof // Proof is 48-bytes
}A Blob represents 128kB of raw data, while a Commitment is a 48-byte cryptographic hash generated by applying a cryptographic commitment scheme (for example, KZG commitment) to the blob data. This provides a compact and efficient method for verifying the integrity of the blob data. The Proof, which is also 48 bytes, is generated by the commitment scheme and allows validators to verify that the blob data corresponds to the on-chain commitment without needing access to the full blob.
How to Generate a Blob Transaction
Blob data contains large amounts of off-chain data, such as rollup proofs from an L2 chain, which are required for rollup verification. In the context of IoTeX, blob data can also include device data generated by IoTeX’s W3bstream devices. This capability enables a wide range of IoT use cases, where data such as sensor readings or event logs can be efficiently bundled and posted to the blockchain.
To create blob data and associated transactions, use the Ethereum SDK or a similar toolkit. See the code example below:
How to Send the Blob Transaction to IoTeX Blockchain
The IoTeX blockchain is fully compatible with Ethereum, so it can accept Blob Transactions using its RPC interface. See the code example below to send a Blob Transaction to the IoTeX blockchain.
Once the Blob Transaction has been successfully sent to the IoTeX blockchain, it will be mined into a block and retained in ephemeral storage for a short period (approximately 20 days).
How to Fetch a Given Blob Transaction from IoTeX Blockchain
You can access the IoTeX RPC endpoint to retrieve any transaction (including a Blob Transaction) by its hash. See the code example below:
How to Verify the Received Blob Transaction
Once the Blob Transaction has been retrieved, you can verify it by checking the commitment against the raw blob data. The verification process consists of two steps:
Verify that the lengths of hashes, blobs, commitments, and proofs match, and that the blob hashes match the hashes in the transaction.
Verify the blob data against the commitments and proofs.
See the code example below:
Reference
EIP-4844: https://eips.ethereum.org/EIPS/eip-4844
Ethereum code base: https://github.com/ethereum/go-ethereum

