Moralis Web3API.resolve

2022-05-13 10:35 更新

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"
}


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号