ERC-7617 web3 URL chunked content delivery (Chunk support for ERC-5219 mode in Web3 URL)
Draft · Other · created 2024-02-08
Content provided at a web3:// address can be split into multiple chunks and received sequentially. This makes it possible to serve large content that cannot be fetched all at once.
Why it is needed
On Ethereum, content such as a website can be stored in a smart contract and served through an address scheme called web3://. However, the RPC endpoint used to read the data has a gas limit, which caps the amount of data that can be returned in a single call. If the content is large, this limit is hit and the content cannot be fully retrieved. This standard defines a way to split content into multiple chunks and include an HTTP header in each response indicating the address of the next chunk. The client follows that address to receive each chunk in sequence, repeating until no more headers are present. This makes it possible to serve content of arbitrary size without being blocked by the gas limit.
In depth
Prerequisite standards
This standard extends ERC-6944 resolve mode within the context of the ERC-6860 web3:// standard. The requires field in the preamble lists ERC-5219 and ERC-6944. Rather than creating a new interface, it adds a single optional HTTP header on top of the value returned by the request() method defined in ERC-6944. Therefore, to use this standard, the target smart contract serving the content must use ERC-6944 resolve mode.
Definition of the web3-next-chunk header
The only newly defined item is a single optional HTTP header, web3-next-chunk. This header is returned within the headers KeyValue array returned by ERC-6944's request() method. The header value is either a complete web3:// URL or a relative URL pointing to the next chunk of the resource data. The target smart contract that this URL points to must also use ERC-6944 resolve mode.
Client processing procedure
The protocol returns the HTTP status code, HTTP headers, and body from the result of the initial request() call to the web3:// client without delay. If a web3-next-chunk header is present, its URL is resolved. If the URL is invalid or the target contract does not use ERC-6944 resolve mode, the HTTP data streaming ends with an error. Otherwise, request() is called, but the returned statusCode is ignored and the body data is sent as the next chunk. If the response contains another web3-next-chunk header, the same process is repeated until no header appears.
Why the header approach was chosen
The approach of using a header to point to the next chunk was chosen because it requires no change to ERC-6944's request() interface. Also, using a web3:// URL as the header value provides flexibility in how the next chunk is served, for example a different path on the same contract or a different contract, as long as it is a location that can be pointed to by a URL.
Problem being addressed
Ethereum RPC endpoints have a gas limit, and this limit can be reached when serving large content. Adding a chunking feature creates the possibility of serving content of arbitrary size. The Security Considerations section of the source text simply states that no security considerations were identified.
Still at the Draft stage
This proposal was created on February 8, 2024, and its status is Draft. Since it is at the draft stage where content may change or progress may stall, it is advisable to check the latest source text before implementation.