GithubHelp home page GithubHelp logo

my-ens-app's Introduction

This is a sample app showcasing ensjs library to interact with ENS. This project was bootstrapped with Create Eth App.

How to setup

git clone https://github.com/ensdomains/my-ens-app.git
cd my-ens-app
yarn
cd packages/react-app
yarn start

Code guide

This demo app shows three basic ways to integrate ENS into your dapp.

  • Resolve ENS name
  • Support reverse resolution
  • Let users name things

All the logic is in App.js

Instantiate ENS

import ENS, { getEnsAddress } from '@ensdomains/ensjs'
const ensAddress = getEnsAddress('1') // Pass chainId
const ens = new ENS({ provider, ensAddress })

Resolve ENS name

await ens.name(name).getAddress()

Support reverse resolution

Getting reverse name

ens.getName(address)

Setting reverser name

let tx = await ens.setReverseRecord(address)
tx.wait()

Let users name things


let tx = await ens.name(myName).createSubdomain(subdomain)
tx.wait()

As an extra bonus, it shows how to query ENS subgraph to retrieve events such as list of subdomains

query getSubdomains($id: ID!) {
  domain(id: $id) {
    id
    labelName
    subdomains {
      id
      labelName
      labelhash
      name
    }
  }
}

For more detail, please look into our guide

my-ens-app's People

Contributors

makoto avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.