Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

Background

ERC-6860 defines how to translate an HTTP-style Web3 URL into an EVM call.

This article explains and expands on the proposal below.

I also cover other EIPs here.

Overview

The standard translates a URL that uses RFC 3986 syntax, such as web3://uniswap.eth/, into an EVM message.

js
EVMMessage {
   To: 0xaabbccddee.... // where uniswap.eth's address registered at ENS
   Calldata: 0x
   ...
}

RFC 3986 defines the syntax of Uniform Resource Identifiers (URIs), which identify Internet resources.

Main components

  • Scheme. Identifies the URI scheme, for example http, https, or ftp.
  • Authority. Can include a host, port, and user information, as in //user:pass@host:port.
  • Path. Identifies the resource location, for example /path/to/resource.
  • Query. Passes additional information, for example ?key1=value1&key2=value2.
  • Fragment. Refers to a part of a resource, for example #section1.

A scheme starts with a letter and can contain letters, digits, plus signs (+), periods (.), and hyphens (-). Characters that cannot appear directly can be percent-encoded. A space is %20, for example. RFC 3986 also defines relative references against a base URI and normalization for comparing URIs.

Example

https://example.com:8080/path/to/resource?query=123#section2

  • Scheme: https
  • Authority: example.com:8080
  • Path: /path/to/resource
  • Query: query=123
  • Fragment: section2

ERC-6860 modifies parts of ERC-4804.

For more on ERC-4804, see the following article.

[ERC-4804] Calling contracts through HTTP-style Web3 URLs

Motivation

People normally read blockchain data through infrastructure such as RPC nodes, block explorers such as Etherscan, and dapps. Web users rarely interact with onchain content directly. A Web3 URL gives an application a standard way to read such content without relying on a conventional web proxy to translate each request for it.

This is particularly useful when a contract already stores SVG, HTML, or metadata. URI-compatible formats can work with existing web infrastructure while the EVM supplies the content.

Specification

The specification uses Augmented Backus–Naur Form (ABNF), defined in RFC 2234, to express the syntax precisely.

ABNF defines the syntax of protocols and data formats.

Basics

Building blocks
  • Rule. A named definition such as rule = definition.
  • Literal. Characters written directly, such as "text".
  • Alternation. Alternatives separated by /, as in rule1 / rule2.
  • Concatenation. A sequence written as adjacent items, as in rule1 rule2.
Operators
  • = defines a rule.
  • / separates alternatives.
  • () groups elements.
  • [] makes elements optional.
  • * describes repetition.
Numeric and character ranges
  • DIGIT = %x30-39 covers digits from 0 to 9.
  • ALPHA = %x41-5A / %x61-7A covers A to Z and a to z.

Example

text
URI           = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
scheme        = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
hier-part     = "//" authority path-abempty

URI combines a scheme and hierarchy with an optional query and fragment. scheme starts with a letter and allows letters, digits, +, -, and .. This example's hier-part combines an authority and path-abempty.

A Web3 URL is an ASCII string with the following structure.

plaintext
web3URL = schema "://" [ userinfo "@" ] contractName [ ":" chainid ] pathQuery
  • schema. The scheme is either w3 or web3.
plaintext
schema = "w3" / "web3"
  • userinfo. This address becomes the EVM call's from value. If omitted, the protocol uses the zero address, 0x0.
plaintext
userinfo = address
  • contractName. This identifies the EVM call's to address. It may be a hexadecimal address or a domain that a name service such as ENS resolves to an address.
plaintext
contractName = address / domainName
address = "0x" 20( HEXDIG HEXDIG )
domainName = *( unreserved / pct-encoded / sub-delims )
  • chainid. This selects the blockchain. When omitted, the protocol defaults to the main chain associated with the name service provider, for example 1 for ENS. When no name service is used, it defaults to 1.
plaintext
chainid = %x31-39 *DIGIT
  • pathQuery. This contains a path and optional query. Its grammar depends on whether the contract uses manual or auto mode.
plaintext
pathQuery = mPathQuery / aPathQuery

Relative URLs

Resolution modes define how Web3 relative URLs are handled.

plaintext
web3UrlRef = web3URL / relativeWeb3URL
relativeWeb3URL = relPathQuery
relPathQuery = relMPathQuery / relAPathQuery

Example

plaintext
web3://0x1234567890abcdef1234567890abcdef12345678@0xabcdef1234567890abcdef1234567890abcdef12:1/path/to/resource?query=param
  • schema: web3.
  • userinfo: 0x1234567890abcdef1234567890abcdef12345678, the EVM call sender.
  • contractName: 0xabcdef1234567890abcdef1234567890abcdef12, the contract address.
  • chainid: 1, Ethereum mainnet.
  • pathQuery: /path/to/resource?query=param, the resource path and query.

Resolution modes

The protocol supports manual and auto mode.

How the client checks the mode

The client calls resolveMode at the to address. Its Solidity signature is as follows.

js
function resolveMode() external returns (bytes32);

Supported resolution modes

Manual mode

A contract selects manual mode by returning this bytes32 encoding of "manual".

bash
0x6d616e75616c0000000000000000000000000000000000000000000000000000
Auto mode

A contract selects auto mode by returning this bytes32 encoding of "auto".

plaintext
0x6175746f00000000000000000000000000000000000000000000000000000000

A zero result also selects auto mode.

plaintext
0x0000000000000000000000000000000000000000000000000000000000000000

Auto mode is also the fallback if the call errors, for example because the method is absent or reverts.

Other modes

For another return value, the request fails with unsupported resolve mode.

Manual mode

Manual mode uses the raw mPathQuery as the call data.

Manual mode grammar

mPathQuery
plaintext
mPathQuery = mPath [ "?" mQuery ]
mPath

The path uses mPathAbempty. It starts with / or is empty.

plaintext
mPath = mPathAbempty ; begins with "/" or is empty

A nonempty path contains segments and may end in a file extension.

plaintext
mPathAbempty = [ *( "/" segment ) "/" segment [ "." fileExtension ] ]
segment = *pchar ; as in RFC 3986
fileExtension = 1*( ALPHA / DIGIT )

Each segment consists of RFC 3986 pchar characters. A file extension contains at least one letter or digit.

mQuery

The query follows RFC 3986.

plaintext
mQuery = *( pchar / "/" / "?" ) ; as in RFC 3986

Manual mode behavior

If mPathQuery is empty, the call data is / (0x2f). The client treats the call result as ABI-encoded bytes, decodes it, and returns the bytes to the frontend. The default MIME type is text/html. When a file extension is present, the client can derive the MIME type from it.

Relative URLs

Manual mode supports relative references similar to HTTP URLs.

relMPathQuery
plaintext
relMPathQuery = relMPath [ "?" mQuery ]
relMPath

A relative path can take the absolute, no-scheme, or empty form.

plaintext
relMPath = mPathAbsolute ; begins with "/" but not "//"
          / mPathNoscheme ; begins with a non-colon segment
          / mPathEmpty    ; zero characters

An absolute path starts with one slash and can include a file extension.

plaintext
mPathAbsolute = "/" [ segmentNz *( "/" segment ) ] [ "." fileExtension ]

A no-scheme path starts with a segment that contains no colon. It can also include a file extension.

plaintext
mPathNoscheme = segmentNzNc *( "/" segment ) [ "." fileExtension ]
segmentNzNc = 1*( unreserved / pct-encoded / sub-delims / "@" )

An empty path has no characters.

plaintext
mPathEmpty = 0<pchar>

Auto mode

Auto mode uses a path to specify a contract method and arguments. The client maps them to an EVM call and returns the result.

Auto mode grammar

aPathQuery
plaintext
aPathQuery = aPath [ "?" aQuery ]
aPath

The path optionally contains a method and arguments. If it is empty or contains only /, the client calls the contract with empty call data. Otherwise, it encodes the call with the Solidity ABI.

plaintext
aPath = [ "/" [ method *( "/" argument ) ] ]
method

The method names the function to call.

plaintext
method = ( ALPHA / "$" / "_" ) *( ALPHA / DIGIT / "$" / "_" )
argument

An argument can use one of the following grammar rules.

plaintext
argument = boolArg / uintArg / intArg / addressArg / bytesArg / stringArg
  • boolArg. Boolean.
plaintext
boolArg = [ "bool!" ] ( "true" / "false" )
  • uintArg. Unsigned integer.
plaintext
uintArg = [ "uint" [ intSizes ] "!" ] 1*DIGIT
  • intArg. Signed integer type.
plaintext
intArg = "int" [ intSizes ] "!" 1*DIGIT
  • addressArg. Address or resolvable domain.
plaintext
addressArg = [ "address!" ] ( address / domainName )
  • bytesArg. Byte string.
plaintext
bytesArg = [ "bytes!" ] bytes / "bytes1!0x" 1( HEXDIG HEXDIG ) / ... / "bytes32!0x" 32( HEXDIG HEXDIG )
  • stringArg. String.
plaintext
stringArg = "string!" *pchar [ "." fileExtension ]
Type inference

When an argument has no explicit type prefix, the client can infer the following types.

  • A decimal number is uint256.
  • A 32-byte hexadecimal value is bytes32.
  • A 20-byte hexadecimal value is an address.
  • Other hexadecimal byte data is bytes.
  • true and false are bool.
  • Otherwise, resolve the argument as a domain name to an address, or return an error if it cannot be resolved.
aQuery

The query can specify how to encode the response.

plaintext
aQuery = attribute *( "&" attribute )

The returns attribute or its alias returnTypes controls response handling.

plaintext
attribute = attrName "=" attrValue
attrName = "returns" / "returnTypes"
attrValue = [ "(" [ retTypes ] ")" ]
retTypes = retType *( "," retType )
retType = retRawType *( "[" [ %x31-39 *DIGIT ] "]" )
retRawType = "(" retTypes ")" / retBaseType
retBaseType = "bool" / "uint" [ intSizes ] / "int" [ intSize ] / "address" / "bytes" [ bytesSizes ] / "string"
Return data

When the return type attribute is absent or has an empty value, the client treats the call result as an ABI-encoded byte string. For returns=(), it puts the raw result in a JSON array as a single 0x-prefixed hexadecimal string. If types are specified, it decodes the ABI result using those types and serializes them as JSON.

Relative URLs

Auto-mode relative URLs resolve against the current contract. They can refer to the current resource, a / path, or a complete method and argument sequence.

Examples

Example 1a

bash
# 手動モード
web3://w3url.eth/
  1. Resolve w3url.eth through ENS on Ethereum mainnet, chain ID 1.
  2. Call resolveMode() with selector 0xDD473FAE and confirm the result is manual.
  3. Send the call to that address with 0x2F (/) as call data.
  4. Decode the ABI-encoded byte string and return it to the frontend. The default MIME type is text/html.

Example 1b

bash
# 自動モード
web3://w3url.eth/
  1. Resolve w3url.eth through ENS on Ethereum mainnet, chain ID 1.
  2. Call resolveMode() with selector 0xDD473FAE and confirm that the result indicates auto mode.
  3. Call the address with empty call data.
  4. Decode the ABI-encoded byte string and return it to the frontend. The example does not specify a MIME type.

Example 2

text
# 自動モード
web3://cyberbrokers-meta.eth/renderBroker/9999
  1. Resolve cyberbrokers-meta.eth through ENS on Ethereum mainnet, chain ID 1.
  2. Call resolveMode() with selector 0xDD473FAE and confirm auto mode.
  3. Call the resolved address with 0x + keccak("renderBroker(uint256)")[0:4] + abi.encode(uint256(9999)).
  4. Decode the ABI-encoded bytes and return them to the frontend. The example does not specify a MIME type.

Example 3

bash
# 手動モード
web3://vitalikblog.eth:5/
  1. Obtain the ENS address for vitalikblog.eth on chain ID 5, the historical Goerli testnet.
  2. Call resolveMode() and confirm manual mode.
  3. Call the resolved address with 0x2F (/) as call data.
  4. Decode the ABI-encoded bytes and return them to the frontend as text/html.

Example 4

bash
# 手動モード
web3://0xe4ba0e245436b737468c206ab5c8f4950597ab7f:42170/
  1. Call resolveMode() and confirm manual mode.
  2. Call 0xe4ba0e245436b737468c206ab5c8f4950597ab7f on chain ID 42170, Arbitrum Nova, with 0x2F (/) as call data.
  3. Decode the ABI-encoded bytes and return them to the frontend as text/html.

Example 5

bash
# 自動モード
web3://0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/balanceOf/vitalik.eth?returns=(uint256)
  1. Resolve vitalik.eth through ENS on Ethereum mainnet, chain ID 1.
  2. Call the contract's balanceOf(address) function with the resolved address.
  3. Decode the result as uint256 and return it to the frontend as application/json.

Example 6

bash
# 自動モード
web3://0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/balanceOf/vitalik.eth?returns=()
  1. Resolve vitalik.eth through ENS on Ethereum mainnet, chain ID 1.
  2. Call the contract's balanceOf(address) function with the resolved address.
  3. Return the raw result bytes in JSON. The MIME type is application/json.

Complete Web3 URL ABNF

Show the complete Web3 URL ABNF
bash
web3URL         = schema "://" [ userinfo "@" ] contractName [ ":" chainid ] pathQuery
schema          = "w3" / "web3"
userinfo        = address
contractName    = address 
                / domainName
chainid         = %x31-39 *DIGIT

pathQuery       = mPathQuery ; path+query for manual mode
                / aPathQuery ; path+query for auto mode

web3UrlRef      = web3URL 
                / relativeWeb3URL
relativeWeb3URL = relPathQuery
relPathQuery    = relMPathQuery ; Relative URL path+query for manual mode
                / relAPathQuery ; Relative URL path+query for auto mode

mPathQuery      = mPath [ "?" mQuery ]
mPath           = mPathAbempty ; begins with "/" or is empty

relMPathQuery   = relMPath [ "?" mQuery ]
relMPath        = mPathAbsolute ; begins with "/" but not "//"
                / mPathNoscheme ; begins with a non-colon segment
                / mPathEmpty    ; zero characters

mPathAbempty    = [ *( "/" segment ) "/" segment [ "." fileExtension ] ]
mPathAbsolute   = "/" [ segmentNz *( "/" segment ) ] [ "." fileExtension ]
mPathNoscheme   = segmentNzNc *( "/" segment ) [ "." fileExtension ]
mPathEmpty      = 0<pchar>

segment         = *pchar ; as in RFC 3986
segmentNz       = 1*pchar ; as in RFC 3986
segmentNzNc     = 1*( unreserved / pct-encoded / sub-delims / "@" )
                ; as in RFC 3986: non-zero-length segment without any colon ":"

mQuery          = *( pchar / "/" / "?" ) ; as in RFC 3986

aPathQuery      = aPath [ "?" aQuery ]
aPath           = [ "/" [ method *( "/" argument ) ] ]
relAPathQuery   = aPath [ "?" aQuery ]
method          = ( ALPHA / "$" / "_" ) *( ALPHA / DIGIT / "$" / "_" )
argument        = boolArg
                / uintArg
                / intArg
                / addressArg
                / bytesArg
                / stringArg
boolArg         = [ "bool!" ] ( "true" / "false" )
uintArg         = [ "uint" [ intSizes ] "!" ] 1*DIGIT
intArg          = "int" [ intSizes ] "!" 1*DIGIT
intSizes        = "8" / "16" / "24" / "32" / "40" / "48" / "56" / "64" / "72" / "80" / "88" / "96" / "104" / "112" / "120" / "128" / "136" / "144" / "152" / "160" / "168" / "176" / "184" / "192" / "200" / "208" / "216" / "224" / "232" / "240" / "248" / "256"
addressArg      = [ "address!" ] ( address / domainName )
bytesArg        = [ "bytes!" ] bytes
                / "bytes1!0x" 1( HEXDIG HEXDIG )
                / "bytes2!0x" 2( HEXDIG HEXDIG )
                / "bytes3!0x" 3( HEXDIG HEXDIG )
                / "bytes4!0x" 4( HEXDIG HEXDIG )
                / "bytes5!0x" 5( HEXDIG HEXDIG )
                / "bytes6!0x" 6( HEXDIG HEXDIG )
                / "bytes7!0x" 7( HEXDIG HEXDIG )
                / "bytes8!0x" 8( HEXDIG HEXDIG )
                / "bytes9!0x" 9( HEXDIG HEXDIG )
                / "bytes10!0x" 10( HEXDIG HEXDIG )
                / "bytes11!0x" 11( HEXDIG HEXDIG )
                / "bytes12!0x" 12( HEXDIG HEXDIG )
                / "bytes13!0x" 13( HEXDIG HEXDIG )
                / "bytes14!0x" 14( HEXDIG HEXDIG )
                / "bytes15!0x" 15( HEXDIG HEXDIG )
                / "bytes16!0x" 16( HEXDIG HEXDIG )
                / "bytes17!0x" 17( HEXDIG HEXDIG )
                / "bytes18!0x" 18( HEXDIG HEXDIG )
                / "bytes19!0x" 19( HEXDIG HEXDIG )
                / "bytes20!0x" 20( HEXDIG HEXDIG )
                / "bytes21!0x" 21( HEXDIG HEXDIG )
                / "bytes22!0x" 22( HEXDIG HEXDIG )
                / "bytes23!0x" 23( HEXDIG HEXDIG )
                / "bytes24!0x" 24( HEXDIG HEXDIG )
                / "bytes25!0x" 25( HEXDIG HEXDIG )
                / "bytes26!0x" 26( HEXDIG HEXDIG )
                / "bytes27!0x" 27( HEXDIG HEXDIG )
                / "bytes28!0x" 28( HEXDIG HEXDIG )
                / "bytes29!0x" 29( HEXDIG HEXDIG )
                / "bytes30!0x" 30( HEXDIG HEXDIG )
                / "bytes31!0x" 31( HEXDIG HEXDIG )
                / "bytes32!0x" 32( HEXDIG HEXDIG )
stringArg       = "string!" *pchar [ "." fileExtension ]

aQuery          = attribute *( "&" attribute )
attribute       = attrName "=" attrValue
attrName        = "returns"
                / "returnTypes"
attrValue       = [ "(" [ retTypes ] ")" ]
retTypes        = retType *( "," retType )
retType         = retRawType *( "[" [ %x31-39 *DIGIT ] "]" )
retRawType      = "(" retTypes ")"
                / retBaseType
retBaseType      = "bool" / "uint" [ intSizes ] / "int" [ intSize ] / "address" / "bytes" [ bytesSizes ] / "string"
bytesSizes      = %x31-39              ; 1-9
                / ( "1" / "2" ) DIGIT  ; 10-29
                / "31" / "32"          ; 31-32

domainName      = *( unreserved / pct-encoded / sub-delims ) ; As in RFC 3986

fileExtension   = 1*( ALPHA / DIGIT )

address         = "0x" 20( HEXDIG HEXDIG )
bytes           = "0x" *( HEXDIG HEXDIG )

pchar           = unreserved / pct-encoded / sub-delims / ":" / "@" ; As in RFC 3986

pct-encoded     = "%" HEXDIG HEXDIG ; As in RFC 3986

unreserved      = ALPHA / DIGIT / "-" / "." / "_" / "~" ; As in RFC 3986
sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
                / "*" / "+" / "," / ";" / "=" ; As in RFC 3986

Changes from ERC-4804

Corrections

  • Manual mode. ERC-4804 used the path and query as-is. ERC-6860 also uses the extension in the path to choose the MIME type.
  • Auto mode. When the query has no return type attribute, ERC-6860 clarifies that the return data is an ABI-encoded byte string rather than an ABI-encoded bytes32.

Clarifications

  • Formal grammar. The standard defines the URL format in ABNF.
  • Resolution mode. It details how the client chooses a mode.
  • Manual mode. It specifies percent-encoding, response handling, and MIME type selection.
  • Auto mode. It details argument encoding and the format and handling of returns.

Modifications

  • Protocol names. ERC-6860 removes the ethereum-web3:// and eth-web3:// schemes from ERC-4804.
  • Auto mode types. ERC-4804 supported uint256, bytes32, address, bytes, and string. ERC-6860 supports more types.
  • Auto mode integer encoding. ERC-4804 encoded returned integers as strings. ERC-6860 uses 0x-prefixed hexadecimal strings in line with Ethereum JSON-RPC.

Rationale

The proposal aims to add a decentralized presentation layer to Ethereum. Human-readable URLs can reference onchain web content such as HTML, CSS, JPG, PNG, and SVG. The EVM acts as a decentralized backend for serving that content.

Design principles

Readability

Web3 URLs should be as recognizable as ordinary web URLs such as http://. Names are easier to read than hexadecimal addresses, and method names and arguments are easier to read than raw hexadecimal call data. The client translates these forms into addresses and calldata.

Compatibility with HTTP URLs

Web3 URLs should support familiar URL concepts such as relative paths, queries, fragments, and percent-encoding. Existing browser and HTTP URL support can therefore be adapted with fewer changes, and web users have less new syntax to learn.

Simplicity

Clients infer argument types such as address, bytes32, and uint256 to keep URLs short. Authors can specify a type when inference is insufficient.

Flexibility

A contract can override the default encoding rules to control how the URL identifies the intended web resource.

Citation

Qi Zhou (@qizhou), Chao Pi (@pichaoqkc), Sam Wilson (@SamWilsn), Nicolas Deschildre (@nand2), "ERC-6860: Web3 URL to EVM Call Message Translation [DRAFT]," Ethereum Improvement Proposals, no. 6860, September 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-6860.

Conclusion

ERC-6860 translates HTTP-style Web3 URLs into EVM calls so clients can retrieve onchain content using a familiar URL format.

Questions are welcome via direct message.

Twitter @cardene777

You can find more of my work at these links.

https://chaldene.net/