EIPs Explained

ERC-2390 · Stagnant · ERC · 2019-11-15

ERC-2390: Geo-ENS

Proposed an ENS resolver extension that stores records per geohash location, so one name can return different addresses or resources depending on where the query is about (GeoDNS for ENS).

What problem does it solve?

Traditional GeoDNS returns different answers depending on where a request comes from, which CDNs use to send users to a nearby server. ENS (EIP-137) has no such notion: a name resolves to the same record for everyone.

GeoENS adds location to resolution. Unlike GeoDNS, it does not guess your location from your IP address: the query includes a location. That means you can ask about any place, not just your own, and you can get back a list of all resources in an area and pick the one with the lowest latency yourself. Other suggested uses include contracts tied to physical objects, location-gated access, and serving localized content via IPFS (EIP-1062).

How it works

Locations are geohashes: base-32 strings that interleave latitude and longitude bits. Longer strings mean smaller areas; GeoENS uses up to 8 characters, which the spec puts at about ±20 m. A shorter prefix covers a bounding box containing all longer hashes that start with it.

Two functions are added to a resolver:

  • setGeoAddr(node, geohash, addr): store addr for an ENS node at an exact 8-character geohash (only callable by the node's owner). Setting address(0) removes it.
  • geoAddr(node, geohash): return all addresses for that node whose geohash starts with the given prefix.

The idea is meant to extend to other record types (DNS records via EIP-1185, text, ABI, content hash).

The reference implementation stores records in a sparse tree with fan-out 32 (one branch per geohash character) and depth 8, and walks it breadth-first to collect results.

Sample code

Interface as described in the spec:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IGeoENSResolver {
    event GeoENSRecordChanged(bytes32 indexed node, bytes8 geohash, address addr);

    function setGeoAddr(bytes32 node, string calldata geohash, address addr) external;
    function geoAddr(bytes32 node, string calldata geohash)
        external view returns (address[] memory);
}

Querying everything in an area with ethers v6:

import { Contract, namehash } from "ethers";

const resolver = new Contract(resolverAddress, [
  "function geoAddr(bytes32 node, string geohash) view returns (address[])",
], provider);

// 5-character geohash prefix = a cell of a few km
const nearby: string[] = await resolver.geoAddr(namehash("cdn.example.eth"), "u4pru");

Things to know

  • Status: Stagnant. The proposal was never finalized, so do not expect standard ENS resolvers to support these functions.
  • The spec's interface takes string geohashes, but its reference implementation uses bytes8 plus a precision argument and registers interface ID 0x8fbcc5ce via ERC-165. An implementer would need to settle on one form.
  • Privacy: the query region usually contains the user's own location. If you use a light client or a hosted RPC provider, that region is visible to the node operator. Only a self-run or trusted full node avoids the leak.
  • Storing a 32-way tree on-chain is costly; result lists in the reference code are capped at a fixed size.

#ens #resolver #geolocation #naming

Details

Authors
James Choncholas (@james-choncholas)
Status
Stagnant
Type
Standards Track / ERC
Created
2019-11-15
Requires

Machine-readable: Markdown · JSON