EIPs/EIPS/eip-2520.md
Pandapip1 9e393a79d9
Force usage of included LICENSE file (#5055)
* Include LICENCE in the Jekyll build

* Replace old licence link with new and improved licence link

* Add note to EIP-1 mandating the new link

* Maybe this fixes it?

* Rename LICENCE so that jekyll picks it up

* Add original LICENCE file back

* Delete the markdown file

* Add Jekyll header

Hopefully the tooling still detects it as CC0

* Remove Jekyll header

* Maybe this will trick Jekyll and satisfy github?

* Remove config changes

* Enable incremental build

* Will it work if I rename it?

* I'll just paste the content of the licence into the file...

* Perhaps this will work

* Replace the licence file

* Fix false positive

Co-authored-by: Micah Zoltu <micah@zoltu.net>

* Resolve feedback

* Perhaps this might work

* It didn't work

This reverts commit 55116e15168fb20ae57dea97388bb260c0941465.

* Will licencee still detect this correctly?

* Jekyll Preamble in licence file

* Include it?

* Licence -> License, get rid of CC0.md

* Force wording of copyright waiver

* Formatting consistent with the rest of the list

* Spelling

* Escape

* Task failed successfully

* Fix two more links

* Will this render it?

* Perhaps this will work too

* .md essential

* Fix the issues Micah noted

Co-authored-by: Micah Zoltu <micah@zoltu.net>
2022-05-06 00:29:09 -07:00

3.9 KiB

eip title author discussions-to status type category created requires
2520 Multiple contenthash records for ENS Filip Štamcar (@filips123) https://github.com/ethereum/EIPs/issues/2393 Stagnant Standards Track ERC 2020-02-18 1577

Simple Summary

ENS support for multiple contenthash records on a single ENS name.

Motivation

Many applications are resolving ENS names to content hosted on distributed systems. To do this, they use contenthash record from ENS domain to know how to resolve names and which distributed system should be used.

However, the domain can store only one contenthash record which means that the site owner needs to decide which hosting system to use. Because there are many ENS-compatible hosting systems available (IPFS, Swarm, recently Onion and ZeroNet), and there will probably be even more in the future, lack of support for multiple records could become problematic. Instead, domains should be able to store multiple contenthash records to allow applications to resolve to multiple hosting systems.

Specification

Setting and getting functions MUST have the same public interface as specified in EIP 1577. Additionally, they MUST also have new public interfaces introduced by this EIP:

  • For setting a contenthash record, the setContenthash MUST provide additional proto parameter and use it to save the contenthash. When proto is not provided, it MUST save the record as default record.

    function setContenthash(bytes32 node, bytes calldata proto, bytes calldata hash) external authorised(node);
    
  • For getting a contenthash record, the contenthash MUST provide additional proto parameter and use it to get the contenthash for requested type. When proto is not provided, it MUST return the default record.

    function contenthash(bytes32 node, bytes calldata proto) external view returns (bytes memory);
    
  • Resolver that supports multiple contenthash records MUST return true for supportsInterface with interface ID 0x6de03e07.

Applications that are using ENS contenthash records SHOULD handle them in the following way:

  • If the application only supports one hosting system (like directly handling ENS from IPFS/Swarm gateways), it SHOULD request contenthash with a specific type. The contract MUST then return it and application SHOULD correctly handle it.

  • If the application supports multiple hosting systems (like MetaMask), it SHOULD request contenthash without a specific type (like in EIP 1577). The contract MUST then return the default contenthash record.

Rationale

The proposed implementation was chosen because it is simple to implement and supports all important requested features. However, it doesn't support multiple records for the same type and priority order, as they don't give much advantage and are harder to implement properly.

Backwards Compatibility

The EIP is backwards-compatible with EIP 1577, the only differences are additional overloaded methods. Old applications will still be able to function correctly, as they will receive the default contenthash record.

Implementation

contract ContentHashResolver {
    bytes4 constant private MULTI_CONTENT_HASH_INTERFACE_ID = 0x6de03e07;
    mapping(bytes32=>mapping(bytes=>bytes)) hashes;

    function setContenthash(bytes32 node, bytes calldata proto, bytes calldata hash) external {
        hashes[node][proto] = hash;
        emit ContenthashChanged(node, hash);
    }

    function contenthash(bytes32 node, bytes calldata proto) external view returns (bytes memory) {
        return hashes[node][proto];
    }

    function supportsInterface(bytes4 interfaceID) public pure returns(bool) {
        return interfaceID == MULTI_CONTENT_HASH_INTERFACE_ID;
    }
}

Security Considerations

TBD

Copyright and related rights waived via CC0.