codecamp

Moralis Web3API.resolve

resolveDomain

解析 Unstoppable 域并返回地址(异步)。

选项:

  • currency​(可选):要查询的货币。 可用值:eth、0x1。 默认值:eth。
  • domain ​(必填): 需要解析的域。

你可以使用​JS​、​React​、​curl​、​Unity​来实现

// get polygon NFTs for address
const options = { currency: "eth", domain: "brad.crypto" };
const resolve = await Moralis.Web3API.resolve.resolveDomain(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";

const Web3Api = useMoralisWeb3Api();

const fetchDomain = async () => {
  // get polygon NFTs for address
  const options = { currency: "eth", domain: "brad.crypto" };
  const resolve = await Web3Api.resolve.resolveDomain(options);
  console.log(resolve);
};
curl -X 'GET' \
  'https://deep-index.moralis.io/api/v2/resolve/brad.crypto?currency=eth' \
  -H 'accept: application/json' \
  -H 'X-API-Key: MY-API-KEY'
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;

  public async void fetchDomain()
  {
    Resolve resolve = await MoralisInterface.GetClient().Web3Api.Resolve.ResolveDomain(domain: "brad.crypto" currency: "eth");
    print(resolve.ToJson());
  }

示例结果

{
  "address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e"
}

resolveAddress

反向解析地址并返回 ENS 域(如果存在)。

选项:

  • address​(必填):要反向解析的以太坊地址。

你可以使用​JS​、​React​、​curl​、​Unity​来实现

// get ENS domain of an address
const options = { address: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" };
const resolve = await Moralis.Web3API.resolve.resolveAddress(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";

const Web3Api = useMoralisWeb3Api();

const fetchAddress = async () => {
  // get ENS domain of an address
  const options = { address: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" };
  const resolve = await Web3Api.resolve.resolveAddress(options);
  console.log(resolve);
};
curl -X 'GET' \
  'https://deep-index.moralis.io/api/v2/resolve/0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045/reverse' \
  -H 'accept: application/json' \
  -H 'X-API-Key: MY-API-KEY'
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;

  public async void fetchAddress()
  {
    Ens result = await MoralisInterface.GetClient().Web3Api.Resolve.ResolveAddress(address: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045");
    print(result.ToJson());
  }

示例结果:

{
  "name": "vitalik.eth"
}


Moralis Web3API.storage (IPFS)
Moralis NFT API
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

Moralis 文件

Moralis 工具

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }