Revolutionizing Address Resolution: EIP 181 and ENS Support for Reverse Resolution

Revolutionizing Address Resolution: EIP 181 and ENS Support for Reverse Resolution https://celo.academy/uploads/default/optimized/2X/c/c5ce326e6095456a9845049aa14537c573b34db6_2_1024x576.png
none 0.0 0

Introduction

One of the most important aspects of any blockchain-based system is the ability to easily and securely identify users. In the Ethereum ecosystem, this is typically done through the use of public addresses. However, public addresses are long and difficult to remember, which can make it difficult for users to interact with decentralized applications (DApps).
Let’s get started!

🗈 Prerequisites

  • A computer with an internet connection. You will need a computer with a stable internet connection to follow along with this guide.

  • Basic knowledge of programming. While we will provide step-by-step instructions, it will be helpful to have some basic knowledge of programming languages such as JavaScript and Solidity.

  • Node.js and npm installed. You will need to have Node.js and npm (the package manager for Node.js) installed on your computer. You can check if you have them installed by running the following commands in your terminal:

node -v
npm -v
  • A code editor. You will need a code editor to write and edit your code. Some popular options include Visual Studio Code and Atom.
  • A Metamask account. You will need a Metamask account to interact with the Celo blockchain from your web browser. If you don’t already have one, you can create one by installing the Metamask extension for Chrome or Firefox.

:warning: Requirements

  • Truffle: a development environment, testing framework, and asset pipeline for Ethereum
  • Node.js: a JavaScript runtime that allows you to run JavaScript on the command line
  • Yarn: a package manager for JavaScript
  • next: Next.js is a framework for building server-rendered or statically-exported React applications.
  • CeloCli - The celocli lets you interact with the Celo Protocol smart contracts.

EIP 181

EIP 181 is an Ethereum Improvement Proposal that introduces a new mechanism for reverse resolution of Ethereum addresses. With reverse resolution, users can associate a human-readable name with their public address. This makes it much easier for users to interact with DApps and other blockchain-based services.

ENS Support for Reverse Resolution

The Ethereum Name Service (ENS) is a decentralized naming system that allows users to register human-readable names for their Ethereum addresses. ENS already supports forward resolution, which allows users to resolve a human-readable name to an Ethereum address. With EIP 181, ENS will also support reverse resolution, which allows users to resolve an Ethereum address to a human-readable name.

Benefits of Reverse Resolution

There are several benefits to reverse resolution. First, it makes it much easier for users to interact with DApps and other blockchain-based services. Second, it can help to improve the security of blockchain-based systems. Third, it can help to increase the adoption of blockchain technology.

Benefit 1: Easier to Interact with DApps and Blockchain-Based Services

One of the biggest benefits of reverse resolution is that it makes it much easier for users to interact with DApps and other blockchain-based services. When users have to remember long and difficult-to-type public addresses, it can be a major barrier to entry. With reverse resolution, users can simply type in a human-readable name instead, which makes it much easier to get started.

Benefit 2: Improved Security

Reverse resolution can also help to improve the security of blockchain-based systems. When users have to type in their public addresses manually, there is a risk of making a mistake and entering the wrong address. This can lead to funds being lost. With reverse resolution, users can simply click on a link to the DApp or service they want to use, which eliminates the risk of human error.

Benefit 3: Increased Adoption of Blockchain Technology

Reverse resolution can also help to increase the adoption of blockchain technology. When blockchain-based systems are easier to use, more people will be willing to adopt them. This can lead to a wider range of applications and services being developed on top of blockchain technology, which will benefit the entire ecosystem.

Cons of Reverse Resolution

While there are many benefits to reverse resolution, there are also some potential drawbacks. One concern is that it could make it easier for scammers to target users. If scammers know that users are more likely to click on links to DApps and services that have human-readable names, they may be more likely to create fake DApps and services with malicious intent.

Another concern is that reverse resolution could lead to a decrease in privacy. When users associate their public addresses with human-readable names, it becomes easier for others to track their activity on the blockchain. This could be a problem for users who value their privacy.

Smart Contract for Reverse Resolution

// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.0;

contract ReverseResolver {

    // Mapping from Ethereum addresses to human-readable names.
    mapping(address => string) public addressToName;
    mapping(string => address) public nameToAddress;

    // Function to set the human-readable name for an Ethereum address.
    function setAddressName(address _address, string memory _name) public {
        require(_address != address(0), "Invalid address");
        require(bytes(_name).length > 0, "Name cannot be empty");

        addressToName[_address] = _name;
        nameToAddress[_name] = _address;
    }

    // Function to get the human-readable name for an Ethereum address.
    function getAddressName(address _address) public view returns (string memory) {
        return addressToName[_address];
    }

    // Function to get the Ethereum address for a human-readable name.
    function getNameAddress(string memory _name) public view returns (address) {
        return nameToAddress[_name];
    }
}

ReverseResolver Contract

Mappings

  • addressToName: Associates Ethereum addresses (address) with human-readable names (string).
  • nameToAddress: Associates human-readable names (string) with Ethereum addresses (address).

setAddressName Function

  • Sets the human-readable name for a given Ethereum address.
  • Parameters:
    • _address (address): The Ethereum address.
    • _name (string): The human-readable name.
  • Validations:
    • Ensures that the address is not zero (invalid).
    • Ensures that the name is not empty.
  • Updates both mappings (addressToName and nameToAddress) to establish bidirectional mapping.

getAddressName Function

  • Retrieves the human-readable name for a given Ethereum address.
  • Parameters:
    • _address (address): The Ethereum address.
  • Returns the associated name.

getNameAddress Function

  • Retrieves the Ethereum address for a given human-readable name.

Parameters:

  • _name (string): The human-readable name.
  • Returns the associated address.

The ReverseResolver contract provides a convenient way to map Ethereum addresses to human-readable names and retrieve them in both directions. It can be used in various scenarios where you need to associate identifiable names with Ethereum addresses.

Conclusion

Overall, the benefits of reverse resolution outweigh the potential drawbacks. Reverse resolution makes it easier for users to interact with DApps and other blockchain-based services, which can help to improve the security of these systems and increase the adoption of blockchain technology. However, it is important to be aware of the potential risks associated with reverse resolution and take steps to protect your privacy.

About Author

Hi! My name is Kunal Dawar and I am a Full Stack web2/web3 Developer. I have participated in numerous hackathons and have been fortunate enough to win many of them.

One thing that I am truly passionate about is creating things that are reliable and don’t break easily. I believe that creating high-quality products is important not only for the users but also for the overall growth and success of a business.

In my free time, I enjoy learning about new technologies and staying up-to-date with the latest trends in the field. I also love to share my knowledge with others and mentor those who are interested in pursuing a career in web development.

References

5 Likes

@Kunaldawar Intresting tutorial, I’ll be reviewing this.

1 Like

@Kunaldawar tutorial looks good. you can move to publish

2 Likes

Amazing insights.

Welldone!

1 Like

Great job on this technical tutorial! Your explanation of EIP 181 and ENS support for reverse resolution is clear and concise, making it easy for readers to understand the concepts