Skip to content

Commit

Permalink
Update eip-4804.md (ethereum#5153)
Browse files Browse the repository at this point in the history
- Remove name resolving (will create EIPs separately)
- Use the domain name as fallback for auto-type detection
  • Loading branch information
qizhou authored and nachomazzara committed Jan 13, 2023
1 parent 24cb06f commit 0a514f3
Showing 1 changed file with 12 additions and 32 deletions.
44 changes: 12 additions & 32 deletions EIPS/eip-4804.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ A Web3 URL is in the following form

```
Web3URL = "web3://" [userinfo "@"] contractName [":" chainid] ["->(" returnTypes ")"] path [? query]
contractName = address | name "." nsProviderSuffix
contractName = address | [name "." [ subDomain0 "." ... ]] nsProviderSuffix
path = ["/" method ["/" argument_0 ["/" argument_1 ... ]]]
argument = [type "!"] value
```
Expand All @@ -43,8 +43,8 @@ where

- "web3://" indicates the Web3 URL **schema**.
- **userinfo** indicates which user is calling the EVM, i.e., "From" field in EVM call message. If not specified, the protocol will use 0x0 as the sender address.
- **contractName** indicates the contract to be called, i.e., "To" field in the EVM call message. If the **contractName** is an **address**, i.e., 0x + 20-byte-data hex, then "To" will be the address. Otherwise, the name is from a name service. In the second case, **nsProviderSuffix** will be the suffix from name service providers such as "eth", "w3q", etc. The way to translate the name from a name service to an address will be discussed in later sections.
- **chainid** indicates which chain to resolve **contractName** and call the message. If not specified, the protocol will use the same chain as the name service provider, e.g., 1 for eth, and 333 for w3q. If no name service provider is available, the default chainid is 1.
- **contractName** indicates the contract to be called, i.e., "To" field in the EVM call message. If the **contractName** is an **address**, i.e., 0x + 20-byte-data hex, then "To" will be the address. Otherwise, the name is from a name service. In the second case, **nsProviderSuffix** will be the suffix from name service providers such as "eth", etc. The way to translate the name from a name service to an address will be discussed in later EIPs.
- **chainid** indicates which chain to resolve **contractName** and call the message. If not specified, the protocol will use the same chain as the name service provider, e.g., 1 for eth. If no name service provider is available, the default chainid is 1.
- **returnTypes** tells the format of the returned data. If not specified, the returned message data will be parsed in "(bytes32)" and MIME will be set based on the suffix of the last argument. If **returnTypes** is "()", the returned data will be parsed in raw bytes in JSON. Otherwise, the returned message will be parsed in the specified "returnTypes" in JSON.

### Resolve Mode
Expand All @@ -66,63 +66,43 @@ The auto mode is the default mode to resolve (also applies when the "resolveMode
2. **type**="bytes32", if **value** is in the form of 0x+32-byte-data hex; or
3. **type**="address", if **value** is in the form of 0x+20-byte-data hex; or
4. **type**="bytes", if **value** is in the form of 0x followed by any number of bytes besides 20 or 32; or
5. else **type**="string".
5. else **type**="address" and parse the argument as a domain name in the form of `[name "." [ subDomain0 "." ... ]] nsProviderSuffix`. In this case, the actual value of the argument will be obtained from **nsProviderSuffix**, e.g., eth. If **nsProviderSuffix** is not supported, an unsupported NS provider error will be returned.

Note that if **method** does not exist, i.e., **path** is empty or "/", then the contract will be called with empty calldata.

### Resolving Address from Name Service Providers

The protocol currently supports two name services:
- Ethereum name service with suffix `.eth`; and
- W3 name service with suffix `.w3q`.

#### Resolving Address from ENS
Given **contractName**, the protocol will find the address of the contract using the following steps:
1. Find the `web3` text record on ENS resolver. Return error if the record is an invalid ETH address.
2. If the `web3` text record does not exist, the protocol will use ETH address of **name**.

Note that `web3` text record may return an Ethereum address or an EIP-3770 chain-specific address. If the address is an EIP-3770 chain-specific address, then the chainid to call the message will be overridden by the chainid specified by the EIP-3770 address.

#### Resolving Address from W3NS

Given **contractName**, the protocol will find the address of the contract using the following steps:
1. Find the Web handler record on W3NS resolver. Return error if the record is an invalid ETH address.
2. If the Web handler record does not exist, the protocol will use ETH address of **name**.


### Examples

#### Example 1

```
web3://ensdomains.eth:4/
web3://enshomepage.eth/
```

The protocol will find the address of **ensdomains.eth** from ENS in chainid 4 (Rinkeby). If the `web3` text record of **ensdomains.eth** on chainid 4 is an Ethereum address, then the protocol will call the address with "From" = "0x..." and "Calldata" = "0x" with chainid = 4. If the `web3` text record of **ensdomains.eth** on chainid 4 is an EIP-3770 chain-specific address, e.g., "rop:0x...", then the protocol will call the address with "From" = "0x..." and "Calldata" = "0x" with the chainid specified by the `web3` text record (ropsten in the example).
The protocol will find the address of **enshomepage.eth** from ENS in chainid 1 (Mainnet), and then the protocol will call the address with "From" = "0x..." and "Calldata" = "0x".

#### Example 2

```
web3://0x9e081Df45E0D167636DB9C61C7ce719A58d82E3b:4
web3://cyberbrokers-meta.eth/renderBroker/9999
```

The protocol will call the address with "To" = "0x9e081Df45E0D167636DB9C61C7ce719A58d82E3b" and "Calldata" = "0x" with chainid = 4.
The protocol will find the address of **cyberbrokers-meta.eth** from ENS on chainid 1 (Mainnet), and then call the address with "To" = "0x..." and "Calldata" = "0x" + `keccak("view(uint256)")[0:4] + abi.encode(uint256(9999))`.

#### Example 3

```
web3://cyberbrokers-meta.eth:1/renderBroker/9999
web3://ensdomains.eth:4/
```

The protocol will find the address of **cyberbrokers-meta.eth** from ENS, and then call the address with "To" = "0x..." and "Calldata" = "0x" + `keccak("view(uint256)")[0:4] + abi.encode(uint256(9999))` with chainid = 1.
The protocol will find the address of **ensdomains.eth** from ENS on chainid 4 (Rinkeby), and then call the address with "From" = "0x..." and "Calldata" = "0x" with chainid = 4.

#### Example 4

```
web3://home.w3q:3334/
web3://0x9e081Df45E0D167636DB9C61C7ce719A58d82E3b:4
```

The protocol will find the address of **home.w3q** from W3NS, and then call the address with "From" = "0x..." and "Calldata" = "0x" with chainid = 3334.
The protocol will call the address with "To" = "0x9e081Df45E0D167636DB9C61C7ce719A58d82E3b" and "Calldata" = "0x" with chainid = 4.

#### Example 5

Expand Down

0 comments on commit 0a514f3

Please sign in to comment.