In solidity, how can I attach blob data to a transaction?

2 Answers 2


You cannot attach blob data to a transaction from within a contract in Solidity. EIP-4844 transactions have a static field, blob_versioned_hashes, which is an array of hashed blob KZG commitments (up to MAX_BLOB_GAS_PER_BLOCK / GAS_PER_BLOB in length, currently 6 blobs / block as of the Cancun hardfork.) As calls made at runtime within the EVM just spawn sub-contexts, they cannot change the statically declared transaction context that the tx.origin defined (i.e., we also can't send EIP-1559 transactions from within a legacy transaction within Solidity).

The actual blob data is available on the consensus layer, and is gossipped between subnets over p2p as sidecars to the beacon blocks. The TransactionPayload is extended for 4844 transactions when gossipped to rlp([tx_payload_body, blobs, commitments, proofs]) as well. Each versioned_hash in the tx payload body (blob_versioned_hashes) must have a direct commitment and proof to match, which allows the node to validate the transaction it received over p2p. The validation rules can be found in the spec.


To effectively address the question of how to send a transaction with a blob in Solidity, particularly in the context of Ethereum's ongoing protocol development (like EIP-4844, part of Ethereum's scaling solutions), we need to understand the limitations of Solidity with regard to transaction types and blob data.

Understanding the Context: EIP-4844

EIP-4844, often referred to as "proto-danksharding," introduces a new type of transaction that includes blob data to help scale Ethereum by offloading some data storage responsibilities from the main chain. It aims to reduce fees and improve throughput by allowing the inclusion of large data sets (blobs) that are not necessarily executed but are available for use by layer 2 protocols.

Solidity's Limitations

In Solidity, the high-level language for Ethereum smart contracts, there is currently no direct method to include blob data within a transaction from a contract. This is primarily because Solidity operates within the constraints of the Ethereum Virtual Machine (EVM), which strictly manages how data and transactions are processed.

  1. Transaction Context: Solidity transactions can’t dynamically include blobs because they operate within a statically defined transaction context initiated by tx.origin. This is a fundamental aspect of EVM's execution model where all actions within a transaction are essentially part of a sub-context spawned by the original transaction. This model ensures security and consistency across state changes.

  2. Static Fields in EIP-4844 Transactions: Transactions that conform to EIP-4844 specifications include a static field named blob_versioned_hashes. This field is an array of hashes corresponding to the KZG (Kate commitments) commitments of the blobs. The size of this array is constrained by gas limits (specifically, MAX_BLOB_GAS_PER_BLOCK / GAS_PER_BLOB), which as of the Cancun hardfork, translates to a maximum of six blobs per block.

Handling Blob Data:

While Solidity does not allow creating or altering blob data within a contract, blob data itself is handled at the consensus layer of Ethereum's architecture:

  1. Consensus Layer and Gossip Protocol: The actual blob data is not stored directly on the Ethereum blockchain but instead exists on the consensus layer. This data is disseminated across networks through a gossip protocol, effectively distributing the data as "sidecars" to beacon blocks.

  2. Transaction Payload and RLP Encoding: In EIP-4844, the transaction payload is extended to include not just the transaction's operational data but also the blobs, their commitments, and proofs. This is encoded using Recursive Length Prefix (RLP) encoding, a method used in Ethereum to serialize objects. The format includes the standard transaction payload alongside the blob data elements.

  3. Validation and Proofs: Each entry in the blob_versioned_hashes must be backed by a valid commitment and proof. These are crucial for nodes in the network to verify the integrity and validity of the blobs that they receive over the peer-to-peer network. Detailed validation rules and mechanisms are specified in the EIP-4844 standard.

*The full text of this answer was passed through GPT-4 with the prompt (notifying according to the policy https://ethereum.stackexchange.com/help/gen-ai-policy): "Correct the grammatical errors without changing the actual meaning of the text"


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.