Usage

We are committed to continuous improvement

Installation

npm i @redefined/name-resolver-js

or download the lib from the NPM registry manually.

Usage

Normal resolution

// initialize resolver
const resolver = new RedefinedResolver();

// resolve redefined names
const emailResult = await resolver.resolve("ik@e2xlabs.com");
/* {
    response: [
        {
            address: "0x6BdfC9Fb0102ddEFc2C7eb44cf62e96356D55d04",
            network: "evm",
            from: "redefined-email"
        }, {
            address: "0x6BdfC9Fb0102ddEFc2C7eb44cf62e96356D55d04",
            network: "bsc",
            from: "redefined-email"
        }
    ],
    errors: [
        {
            vendor: "ens",
            error: "Invalid domain",
        },
    ],
}*/
const nicknameResult = await resolver.resolve("gigachadivan");
/* {
    response: [{
        address: "GsYPSWAbXw4YsSEeowuTf7nqjExVxKS5tS1Yy9WwFAPG",
        network: "sol",
        from: "redefined-username"
    }],
    errors: [],
}*/

// resolve ENS names
const ensResult = await resolver.resolve("ivan.eth");
/* {
    response: [{
        address: "0x25428d29a6FA3629ff401c6DADe418B19CB2D615",
        network: "evm",
        from: "ens"
    }],
    errors: [
        {
            vendor: "redefiend-email",
            error: "Domain is not registered",
        },
    ],
}*/

// resolve Unstoppable names
const unstoppableResult = await resolver.resolve("nick.crypto");
/* {
    response: [{
        address: "0x16d94b922bF11981DBa2C4A6cAEd9938F00d5d0C",
        network: "evm",
        from: "unstoppable"
    }],
    errors: [],
}*/

// resolve specific network
const ethResult = await resolver.resolve("ik@e2xlabs.com", ["eth"]);
/* {
    response: [{
        address: "0x6BdfC9Fb0102ddEFc2C7eb44cf62e96356D55d04",
        network: "eth",
        from: "redefined-email"
    }],
    errors: [],
}*/
const bscFromUnstoppable = await resolver.resolve("nick.crypto", ["bsc"]);
/* {
    response: [{
        address: "0x16d94b922bF11981DBa2C4A6cAEd9938F00d5d0C",
        network: "evm",
        from: "unstoppable"
    }],
    errors: [],
}*/
const solFromBonfida = await resolver.resolve("example", ["sol"]);
/* {
    response: [{
        address: "CiJscHNjYEa6z61bXuYnxLGoLyMiY3mf8vjcx97Dcmxg",
        network: "sol",
        from: "bonfida"
    }],
    errors: [],
}*/
const bscFromSid = await resolver.resolve("nick.bnb");
/*
  {
    response: [{ address: "0xf88353e6b33d1f9f6f325dbcbb697ddd0be3bd5c", network: "bsc", from: "sid", }],
    errors: [],
  }
*/

const arbOneFromSid = await resolver.resolve("nick.arb");
/*
  {
    response: [{ address: "0xf88353e6b33d1f9f6f325dbcbb697ddd0be3bd5c", network: "arbitrum-one", from: "sid", }],
    errors: [],
  }
*/

const arbNovaFromSid = await resolver.resolve("nick.arb");
/*
  {
    response: [{ address: "0xf88353e6b33d1f9f6f325dbcbb697ddd0be3bd5c", network: "arbitrum-nova", from: "sid", }],
    errors: [],
  }
*/

const evmFromLens = await resolver.resolve("aaveaave.lens");
/* {
    response: [{
        address: "0xD4478D18E203c418A1Fd1d89f6518eD9819Ff348",
        network: "evm",
        from: "lens"
    }],
    errors: [],
}*/

// resolve specific vendors
const ethResult = await resolver.resolve("ik@e2xlabs.com", ["eth"], ["ens", "redefined-email"]);
/* {
    response: [{
        address: "0x6BdfC9Fb0102ddEFc2C7eb44cf62e96356D55d04",
        network: "eth",
        from: "redefined-email"
    }],
    errors: [],
}*/

Reverse resolution

// reverse address
const reverseResult = await resolver.reverse("0xb8c2C29ee19D8307cb7255e1Cd9CbDE883A267d5");
/* {
    response: [{
      "domain": "nick.eth",
      "vendor": "ens"
    },
		{
			"domain": "arachnid.lens",
			"vendor": "lens"
		}],
    errors: [],
}*/

// reverse address with specific vendor
const reverseEnsResult = await resolver.reverse("0xb8c2C29ee19D8307cb7255e1Cd9CbDE883A267d5", ["ens"]);
/* {
    response: [{
      "domain": "nick.eth",
      "vendor": "ens"
    }],
    errors: [],
}*/

Priorities of resolution of EVM-compatible

If you need to obtain a BSC or Polygon address without a unique mapping for them, the system will default to using the EVM mapping.

  1. If the desired network address cannot be located, but an EVM address is found, then we will provide you with the EVM address instead.

  2. If the address is found in both the desired network and EVM, only the address from the desired network will be provided.

  3. We will provide all known results if the desired network is not specified.

resolve.resolve("domain", ["eth"]);
// We found [{ address: "0x", network: "eth", from:"redefined" }, { address: "0x", network: "evm", from:"redefined" }]
// You receive [{ address: "0x", network: "eth", from:"redefined" }]

resolve.resolve("domain", ["eth"]);
// We found [{ address: "0x", network: "bsc", from:"redefined" }, { address: "0x", network: "evm", from:"redefined" }]
// You receive [{ address: "0x", network: "evm, from:"redefined" }]

resolve.resolve("domain");
// We found [{ address: "0x", network: "bsc", from:"redefined" }, { address: "0x", network: "evm", from:"redefined" }]
// You receive [{ address: "0x", network: "bsc, from:"redefined" }, { address: "0x", network: "evm", from:"redefined" }]

Last updated