完整文档: https://github.com/nft-api/nft-api
NFT API 消除了使用 NFT 并将 NFT 集成到您的 dapp 中的所有困难。
使用 NFT 通常很困难,因为 NFT 代币标准没有得到很好的遵循,当你开始解析链上 NFT 数据时会出现很多边缘情况。
这就是为什么 NFT API 旨在为跨不同区块链的所有 NFT 代币提供统一接口,这样您就可以专注于您的 dapp,而无需运行自己的 NFT 解析管道。
该 API 最重要的用例是获取与以下相关的跨链数据:
链支持:
端点:
SearchNFTs
非常强大且快速的工具,用于基于元数据搜索(异步)获取 NFT 数据。
选项:
chain
(可选):从中获取数据的区块链。 有效值列在支持的链上。 默认值 Eth。
format
(可选):token id 的格式。 可用值:十进制、十六进制。 默认值:十进制。
offset
(可选):偏移量。
limit
(可选):限制。
q
(必需):搜索字符串参数
filter
(必需):搜索应匹配的字段。 要查看整个元数据,请将值设置为全局。 要获得更好的响应时间,您可以查看特定字段,例如名称。 可用值:name; description; attributes; global; name,description; name,attributes; description,attributes; name,description,attributes你可以使用JS
、React
、curl
、Unity
来实现
const options = { q: "Pancake", chain: "bsc", filter: "name" };
const NFTs = await Moralis.Web3API.token.searchNFTs(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchSearchNFTs = async () => {
const options = { q: "Pancake", chain: "bsc", filter: "name" };
const NFTs = await Web3Api.token.searchNFTs(options);
console.log(NFTs);
};
curl -X "GET"
"https://deep-index.moralis.io/api/v2/nft/search?chain=bsc&format=decimal&q=Pancake&filter=name"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchSearchNFTs()
{
NftMetadataCollection nft = await MoralisInterface.GetClient().Web3Api.Token.SearchNFTs(q: "Pancake", ChainList.bsc, filter: "name");
print(nft.ToJson());
}
示例结果
[
{
token_id: "124436",
token_address: "0x3afa102b264b5f79ce80fed29e0724f922ba57c7",
token_uri:
"https://ipfs.moralis.io:2053/ipfs/QmVAD8v4s2SXF8FgjePqMdQ2GV5hE2isZnzxcrA36XcSDA/metadata.json",
metadata:
"{"name":"Pancake","description":"The dessert series 1","image":"ipfs://QmNQFXCZ6LGzvpMW9Q5PWbCrEnLknQrPwr2r8pbQAgzQ9A/4863BD6B-6C92-4B96-BF80-8020B2F7C3A5.jpeg"}",
contract_type: "ERC721",
token_hash: "d03fe436e972bf9215d7bb8c64c4c556",
synced_at: null,
created_at: "2021-09-19T10:36:16.610Z",
},
];
const options = { q: "bored ape", chain: "bsc", filter: "global" };
const NFTs = await Moralis.Web3API.token.searchNFTs(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchSearchNFTs = async () => {
const options = { q: "bored ape", chain: "bsc", filter: "global" };
const NFTs = await Web3Api.token.searchNFTs(options);
console.log(NFTs);
};
curl -X "GET"
"https://deep-index.moralis.io/api/v2/nft/search?chain=bsc&format=decimal&q=Pancake&filter=global"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchSearchNFTs()
{
NftMetadataCollection nft = await MoralisInterface.GetClient().Web3Api.Token.SearchNFTs(q: "Pancake", ChainList.bsc, filter: "global");
print(nft.ToJson());
}
const options = {
q: "loves bananas",
chain: "bsc",
filter: "description,attributes",
};
const NFTs = await Moralis.Web3API.token.searchNFTs(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchSearchNFTs = async () => {
const options = {
q: "loves bananas",
chain: "bsc",
filter: "description,attributes",
};
const NFTs = await Web3Api.token.searchNFTs(options);
console.log(NFTs);
};
curl -X "GET"
"https://deep-index.moralis.io/api/v2/nft/search?chain=bsc&format=decimal&q=Pancake&filter=description%2Cattributes"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchSearchNFTs()
{
NftMetadataCollection nft = await MoralisInterface.GetClient().Web3Api.Token.SearchNFTs(q: "Pancake", ChainList.bsc, filter: "description,attributes");
print(nft.ToJson());
}
示例结果
"result": [
{
token_id: "854645",
token_address: "0xdf7952b35f24acf7fc0487d01c8d5690a60dba07",
token_uri: "https://ipfs.moralis.io:2053/ipfs/QmYUHFzEvPsoseNWcHtqE18Ao8HPBRktLPoDMKpdDYvHQV",
metadata: "{n "name": "Pancake Christmas 2021",n "description": "A great collab between Chef Cecy and the winner of the #PancakeChristmas event. Merry Christmas, and Happy New Year!",n "mp4_url": "ipfs://QmXYFMtYVBJBKjgGwf6MmrKhVtNdbVjLQCPLCu99hpAu47/christmas-2021.mp4",n "gif_url": "ipfs://QmXYFMtYVBJBKjgGwf6MmrKhVtNdbVjLQCPLCu99hpAu47/christmas-2021.gif",n "webm_url": "ipfs://QmXYFMtYVBJBKjgGwf6MmrKhVtNdbVjLQCPLCu99hpAu47/christmas-2021.webm",n "image": "ipfs://QmXYFMtYVBJBKjgGwf6MmrKhVtNdbVjLQCPLCu99hpAu47/christmas-2021.png",n "attributes": {n "bunnyId": "23"n }n}",
is_valid: 1,
syncing: 2,
frozen: 0,
resyncing: 0,
synced_at: "2022-01-02T19:50:58.391Z",
contract_type: "ERC721",
token_hash: "fffedca3037a8dc03483193b99fa9736",
batch_id: null,
metadata_name: ""Pancake Christmas 2021"",
metadata_description: ""A great collab between Chef Cecy and the winner of the #PancakeChristmas event. Merry Christmas, and Happy New Year!"",
metadata_attributes: "{"bunnyId":"23"}",
block_number_minted: "14022006",
opensea_lookup: null,
minter_address: "0xd338d2d63b55cbb059162394544a473156d513bd",
transaction_minted: "0xd7d0651c5bdf168c83f7a7e6570345bf73b11aabee3da7a6a3126034a77e382d",
frozen_log_index: null,
imported: null,
createdAt: "2022-01-02T19:49:52.234Z",
updatedAt: "2022-01-02T19:49:52.234Z"
}
从当前用户或地址获取所有 NFT。 支持 ERC721 和 ERC1155。 返回具有 NFT 对象数量和 NFT 对象数组(异步)的对象。
选项:
chain
(可选):从中获取数据的区块链。 有效值列在支持的链上。 默认值 Eth。
address
(可选):用户地址(即 0x1a2b3x...)。 如果指定,则附加到查询的用户将被忽略,而是使用地址。你可以使用JS
、React
、curl
、Unity
来实现
// get NFTs for current user on Mainnet
const userEthNFTs = await Moralis.Web3API.account.getNFTs();
// get testnet NFTs for user
const testnetNFTs = await Moralis.Web3API.account.getNFTs({ chain: "ropsten" });
// get polygon NFTs for address
const options = {
chain: "polygon",
address: "0x75e3e9c92162e62000425c98769965a76c2e387a",
};
const polygonNFTs = await Moralis.Web3API.account.getNFTs(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchNFTs = async () => {
// get NFTs for current user on Mainnet
const userEthNFTs = await Web3Api.account.getNFTs();
console.log(userEthNFTs);
// get testnet NFTs for user
const testnetNFTs = await Web3Api.Web3API.account.getNFTs({
chain: "ropsten",
});
console.log(testnetNFTs);
// get polygon NFTs for address
const options = {
chain: "polygon",
address: "0x75e3e9c92162e62000425c98769965a76c2e387a",
};
const polygonNFTs = await Web3Api.account.getNFTs(options);
};
console.log(polygonNFTs);
curl -X "GET"
"https://deep-index.moralis.io/api/v2/0x75e3e9c92162e62000425c98769965a76c2e387a/nft?chain=polygon&format=decimal"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchNFTs()
{
NftOwnerCollection polygonNFTs = await MoralisInterface.GetClient().Web3Api.Account.GetNFTs("0x75e3e9c92162e62000425c98769965a76c2e387a".ToLower(), ChainList.polygon);
print(polygonNFTs.ToJson());
}
示例结果
[
{
token_address: "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
token_id: "15",
contract_type: "ERC721",
owner_of: "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
block_number: "88256",
block_number_minted: "88256",
token_uri: "string",
metadata: "string",
synced_at: "string",
amount: "1",
name: "CryptoKitties",
symbol: "RARI",
},
];
返回具有指定合约的 NFT 计数的对象和属于指定合约的给定地址的 NFT 数组(异步)。
选项:
chain
(可选):从中获取数据的区块链。 有效值列在支持的链上。 默认值 Eth。
format
(可选):token id 的格式。 可用值:十进制、十六进制。 默认值:十进制。
offset
(可选):偏移量。
limit
(可选):限制。
order
(可选):要排序的字段以及是否应按升序或降序排序。
address
(可选):给定令牌的所有者(即 0x1a2b3x...)。 如果指定,则附加到查询的用户将被忽略,而是使用地址。
token_address
(必填): 合约地址你可以使用JS
、React
、curl
、Unity
来实现
const options = {
chain: "polygon",
address: "0x75e3e9c92162e62000425c98769965a76c2e387a",
token_address: "0x2953399124F0cBB46d2CbACD8A89cF0599974963",
};
const polygonNFTs = await Moralis.Web3API.account.getNFTsForContract(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchNFTsForContract = async () => {
const options = {
chain: "polygon",
address: "0x75e3e9c92162e62000425c98769965a76c2e387a",
token_address: "0x2953399124F0cBB46d2CbACD8A89cF0599974963",
};
const polygonNFTs = await Web3Api.account.getNFTsForContract(options);
console.log(polygonNFTs);
};
curl -X "GET"
"https://deep-index.moralis.io/api/v2/0x75e3e9c92162e62000425c98769965a76c2e387a/nft/0x2953399124F0cBB46d2CbACD8A89cF0599974963?chain=polygon&format=decimal"
-H "accept: application/json"
-H "X-API-Key: My-API-KEY"
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchNFTsForContract()
{
NftOwnerCollection polygonNFTs = await MoralisInterface.GetClient().Web3Api.Account.GetNFTsForContract("0x3d6c0e79a1239df0039ec16Cc80f7A343b6C530e".ToLower(),"0x2953399124F0cBB46d2CbACD8A89cF0599974963", ChainList.polygon);
print(polygonNFTs.ToJson());
}
使用 token_address
参数仅获取特定合约的结果。
注意结果将包括所有索引的 NFT
。
任何包含 token_address
参数的请求都将在第一次被请求时启动该 NFT
集合的索引过程。
示例结果
{
total: 5,
page: 0,
page_size: 1,
cursor: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ3aGVyZSI6eyJ0b2tlbl9hZGRyZXNzIjoiMHgyOTUzMzk5MTI0ZjBjYmI0NmQyY2JhY2Q4YTg5Y2YwNTk5OTc0OTYzIiwib3duZXJfb2YiOiIweDc1ZTNlOWM5MjE2MmU2MjAwMDQyNWM5ODc2OTk2NWE3NmMyZTM4N2EifSwibGltaXQiOjEsIm9mZnNldCI6MSwib3JkZXIiOltbInRyYW5zZmVyX2luZGV4IiwiREVTQyJdXSwicGFnZSI6MSwiaWF0IjoxNjQ2NDkxMzYzfQ.2emXTUoQYAV5dcC-05fkX5bHuuCHgL8aSQ2P9nqJPs0",
result: [
{
"token_address": "0x2953399124f0cbb46d2cbacd8a89cf0599974963",
"token_id": "54882136101329053367331551663964422650505490251725779255107807133728757514309",
"block_number_minted": "22364568",
"owner_of": "0x75e3e9c92162e62000425c98769965a76c2e387a",
"block_number": "22728905",
"amount": "1",
"contract_type": "ERC1155",
"name": "OpenSea Collections",
"symbol": "OPENSTORE",
"token_uri": "https://api.opensea.io/api/v2/metadata/matic/0x2953399124F0cBB46d2CbACD8A89cF0599974963/0x7956302fe62df98c5c7f35354a2d03eb8b160f0e000000000000020000000045",
"metadata": null,
"synced_at": "2021-12-10T17:04:09.775Z",
"is_valid": 0,
"syncing": 2,
"frozen": 0
}
],
status: "SYNCED"
}
获取 NFT
转账。 返回具有 NFT
传输次数和 NFT
传输数组(异步)的对象。
选项:
chain
(可选):从中获取数据的区块链。 有效值列在支持的链上。 默认值 Eth。
format
(可选):token id 的格式。 可用值:十进制、十六进制。 默认值:十进制。
offset
(可选):偏移量。
direction
(可选):传输方向。 可用值:both、to、from 。 默认值:两者。
limit
(可选):限制。
order
(可选):要排序的字段以及是否应按升序或降序排序。
address
(可选):用户地址(即 0x1a2b3x...)。 如果指定,则附加到查询的用户将被忽略,而是使用地址。你可以使用JS
、React
、curl
、Unity
来实现
// get mainnet NFT transfers for the current user
const transfersNFT = await Moralis.Web3API.account.getNFTTransfers();
// get BSC NFT transfers for a given address
// with most recent transactions appearing first
const options = {
chain: "polygon",
address: "0x75e3e9c92162e62000425c98769965a76c2e387a",
limit: "5",
};
const transfersNFT = await Moralis.Web3API.account.getNFTTransfers(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchNFTTransfers = async () => {
// get mainnet NFT transfers for the current user
const transfersNFT = await Web3Api.account.getNFTTransfers();
console.log(transfersNFT);
// get BSC NFT transfers for a given address
// with most recent transactions appearing first
const options = {
chain: "polygon",
address: "0x75e3e9c92162e62000425c98769965a76c2e387a",
limit: "5",
};
const bscTransfersNFT = await Web3Api.account.getNFTTransfers(options);
console.log(bscTransfersNFT);
};
curl -X "GET"
"https://deep-index.moralis.io/api/v2/0x75e3e9c92162e62000425c98769965a76c2e387a/nft/transfers?chain=polygon&format=decimal&direction=both&limit=5"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchNFTTransfers()
{
NftTransferCollection BSCnfttransfers = await MoralisInterface.GetClient().Web3Api.Account.GetNFTTransfers("0x3d6c0e79a1239df0039ec16Cc80f7A343b6C530e".ToLower(), ChainList.bsc);
print(BSCnfttransfers.ToJson());
}
使用 token_address
参数仅获取特定合约的结果。
注意结果将包括所有索引的 NFT
。
任何包含 token_address
参数的请求都将在第一次被请求时启动该 NFT
集合的索引过程。
示例结果
[
{
token_address: "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
token_id: "15",
from_address: "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
to_address: "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
amount: "1",
contract_type: "ERC721",
block_number: "88256",
block_timestamp: "2021-06-04T16:00:15",
block_hash: "string",
transaction_hash: "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
transaction_type: "string",
transaction_index: "string",
log_index: 0,
},
];
针对给定的代币合约地址(异步)返回一个包含多个 NFT 的对象和一个包含 NFT 元数据(名称、符号)的数组。
选项:
chain
(可选):从中获取数据的区块链。 有效值列在支持的链上。 默认值 Eth。
format
(可选):token id 的格式。 可用值:十进制、十六进制。 默认值:十进制。
offset
(可选):偏移量。
limit
(可选):限制。
address
(必填):代币合约的地址。你可以使用JS
、React
、curl
、Unity
来实现
const options = {
address: "0x7dE3085b3190B3a787822Ee16F23be010f5F8686",
chain: "eth",
};
const NFTs = await Moralis.Web3API.token.getAllTokenIds(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchAllTokenIds = async () => {
const options = {
address: "0x7dE3085b3190B3a787822Ee16F23be010f5F8686",
chain: "eth",
};
const NFTs = await Web3Api.token.getAllTokenIds(options);
console.log(NFTs);
};
curl -X "GET"
"https://deep-index.moralis.io/api/v2/nft/0x7dE3085b3190B3a787822Ee16F23be010f5F8686?chain=eth&format=decimal"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchAllTokenIds()
{
NftCollection nfts = await MoralisInterface.GetClient().Web3Api.Token.GetAllTokenIds(address: "0x7dE3085b3190B3a787822Ee16F23be010f5F8686" , ChainList.eth);
print(nfts.ToJson());
}
示例结果
[
{
token_address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
token_id: "728",
amount: "1",
contract_type: "ERC721",
name: "Baby Ape Mutant Club",
symbol: "BAMC",
token_uri:
"https://gateway.moralisipfs.com/ipfs/QmajSqgxY3cWBgBeRm38vasJAcTit1kp5EwqVHxszJYgUC/728.json",
metadata:
"{n "name": "Baby Mutant #728",n "description": "",n "image": "ipfs://QmPUDVLP9W1pWpCTpGvpPbMu4nVpCuu2A7M6tQovDpVDoD/728.png",n "dna": "172bef0b78106072e4eacb26db57ae70fb17b37b",n "edition": 728,n "date": 1645023568505,n "artist": "Skurvydogg",n "attributes": [n {n "trait_type": "BackGrounds",n "value": "Putrid_Purple"n },n {n "trait_type": "Furs",n "value": "Red_rum"n },n {n "trait_type": "Eyes",n "value": "Robot_M1"n },n {n "trait_type": "Hats",n "value": "Bunny_Ears_M2"n },n {n "trait_type": "Mouths",n "value": "Xenomorf_M1"n }n ]n}",
synced_at: "2022-03-05T02:29:18.441Z",
},
];
针对给定的代币合约地址(异步)返回一个包含 NFT 传输数量的对象和一个包含 NFT 传输的数组。
选项:
chain
(可选):从中获取数据的区块链。 有效值列在支持的链上。 默认值 Eth。
format
(可选):token id 的格式。 可用值:十进制、十六进制。 默认值为十进制。
offset
(可选):偏移量。
limit
(可选):限制。address
(必填): 合约地址你可以使用JS
、React
、curl
、Unity
来实现
const options = {
address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
chain: "eth",
};
const nftTransfers = await Moralis.Web3API.token.getContractNFTTransfers(
options
);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchContractNFTTransfers = async () => {
const options = {
address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
chain: "eth",
};
const nftTransfers = await Web3Api.token.getContractNFTTransfers(options);
console.log(NFTs);
};
curl -X "GET"
"https://deep-index.moralis.io/api/v2/nft/0x7de3085b3190b3a787822ee16f23be010f5f8686/1/transfers?chain=eth&format=decimal"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchContractNFTTransfers()
{
NftTransferCollection nftTransers = await MoralisInterface.GetClient().Web3Api.Token.GetContractNFTTransfers(address: "0x7de3085b3190b3a787822ee16f23be010f5f8686", ChainList.eth);
print(nftTransfers.ToJson());
}
示例结果
[
{
block_number: "14238158",
block_timestamp: "2022-02-19T18:49:02.000Z",
block_hash:
"0x8124f4a126996d306a90fa00b871b6ed9669a1a9806106b34fa28f3de61e5f8b",
transaction_hash:
"0x2db36892fc17bf99a3f6dd8a639f3c704f772858f3961cbcd26b3a42a2cd561e",
transaction_index: 162,
log_index: 419,
value: "0",
contract_type: "ERC721",
transaction_type: "Single",
token_address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
token_id: "1",
from_address: "0x0000000000000000000000000000000000000000",
to_address: "0x324fb4a58674758e00c3a49409b815de1398bfe8",
amount: "1",
verified: 1,
operator: null,
},
];
返回最近 x 天的 NFT 代币合约价格最低的对象(仅以 ETH 支付的交易)
选项:
chain
(可选):从中获取数据的区块链。 有效值列在支持的链上。 默认值 Eth。
days
(可选):查找最低价格的天数 如果未提供,则默认为 7 天
marketplace
(可选):获取交易的市场(目前仅支持 opensea)。
address
(必填):合约地址(即 0x1a2b3x...)。你可以使用JS
、React
、curl
、Unity
来实现
const options = {
address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
days: "3",
};
const NFTLowestPrice = await Moralis.Web3API.token.getNFTLowestPrice(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchNFTLowestPrice = async () => {
const options = {
address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
days: "3",
};
const NFTLowestPrice = await Web3Api.token.getNFTLowestPrice(options);
console.log(NFTLowestPrice);
};
curl -X "GET"
"https://deep-index.moralis.io/api/v2/nft/0x7de3085b3190b3a787822ee16f23be010f5f8686/lowestprice?chain=eth&days=3&marketplace=opensea"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchNFTLowestPrice()
{
Trade NFTLowestPrice = await MoralisInterface.GetClient().Web3Api.Token.GetNFTLowestPrice(address: "0x7de3085b3190b3a787822ee16f23be010f5f8686", ChainList.eth, days: 2);
print(NFTLowestPrice.ToJson());
}
示例结果
[
{
transaction_hash:
"0xda5f3337eb74b56e99aebb5d9ebfc1e82b1c0aacc3b9b7cc606d4112ba12801d",
transaction_index: "168",
token_ids: ["254"],
seller_address: "0x8a04cea099e2d2886aea08e33446b5a52b9cf900",
buyer_address: "0xcf806faa913b3ac7bcb7b57b1199411a76d96646",
token_address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
marketplace_address: "0x7be8076f4ea4a4ad08075c2508e481d6c946d12b",
price: "0",
block_timestamp: "2022-02-26T17:19:23.000Z",
block_number: "14283046",
block_hash:
"0x997713ef27375f735f7017824958c0f0093236fe7515f8759bead1ce21d554fb",
},
];
返回给定合约(异步)的合约级别元数据(名称、符号、基本令牌 uri)。
选项:
chain
(可选):从中获取数据的区块链。 有效值列在支持的链上。 默认值 Eth。
address
(必填):代币合约的地址。你可以使用JS
、React
、curl
、Unity
来实现
const options = {
address: "0x7dE3085b3190B3a787822Ee16F23be010f5F8686",
chain: "eth",
};
const metaData = await Moralis.Web3API.token.getNFTMetadata(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchNFTMetadata = async () => {
const options = {
address: "0x7dE3085b3190B3a787822Ee16F23be010f5F8686",
chain: "eth",
};
const metaData = await Web3Api.token.getNFTMetadata(options);
console.log(metaData);
};
curl -X "GET"
"https://deep-index.moralis.io/api/v2/nft/0x7dE3085b3190B3a787822Ee16F23be010f5F8686/metadata?chain=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 fetchNFTMetadata()
{
NftContractMetadata metadata = await MoralisInterface.GetClient().Web3Api.Token.GetNFTMetadata(address: "0x7dE3085b3190B3a787822Ee16F23be010f5F8686", ChainList.eth);
print(metadata.ToJson());
}
对尚未索引的合约地址的请求将自动启动该
NFT
集合的索引过程
示例结果
{
"token_address": "0x7de3085b3190b3a787822ee16f23be010f5f8686",
"name": "Baby Ape Mutant Club",
"symbol": "BAMC",
"contract_type": "ERC721",
"synced_at": "2022-02-19"
}
返回具有多个 NFT 所有者的对象和具有给定代币合约地址(异步)的 NFT 元数据(名称、符号)的数组。
选项:
chain
(可选):从中获取数据的区块链。 有效值列在支持的链上。 默认值 Eth。
format
(可选):token id 的格式。 可用值:十进制、十六进制。 默认值:十进制。
offset
(可选):偏移量。
limit
(可选):限制。
address
(必填): 合约地址你可以使用JS
、React
、curl
、Unity
来实现
const options = {
address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
chain: "eth",
};
const nftOwners = await Moralis.Web3API.token.getNFTOwners(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchNFTOwners = async () => {
const options = {
address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
chain: "eth",
};
const nftOwners = await Web3Api.token.getNFTOwners(options);
console.log(nftOwners);
};
curl -X "GET"
"https://deep-index.moralis.io/api/v2/nft/0x7de3085b3190b3a787822ee16f23be010f5f8686/owners?chain=eth&format=decimal"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchNFTOwners()
{
NftOwnerCollection nftowners = await MoralisInterface.GetClient().Web3Api.Token.GetNFTOwners(address: "0x7de3085b3190b3a787822ee16f23be010f5f8686", ChainList.eth);
print(nftowners.ToJson());
}
确保在
token_id
之类的列上包含排序参数,以获得一致的分页结果
对尚未索引的合约地址的请求将自动启动该 NFT 集合的索引过程
示例结果
[
{
token_address: "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
token_id: "15",
contract_type: "ERC721",
owner_of: "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
block_number: "88256",
block_number_minted: "88256",
token_uri: "string",
metadata: "string",
synced_at: "string",
amount: "1",
name: "CryptoKitties",
symbol: "RARI",
},
];
返回给定合约和市场的 NFT 交易对象
选项:
chain
(可选):从中获取数据的区块链。有效值列在支持的链上。默认值 Eth。
from_date
(可选):获取交易的日期(momentjs 接受的任何格式)。提供参数 "from_block" 或 "from_date" 如果提供了 "from_date" 和 "from_block",则将使用 "from_block"。
to_date
(可选):获取到此日期的交易(momentjs 接受的任何格式)。提供参数 "to_block" 或 "to_date" 如果提供了 "to_date" 和 "to_block",将使用 "to_block"。
from_block
(可选):从哪里获得交易的最小区块号提供参数"from_block"或"from_date"如果提供"from_date"和"from_block",将使用"from_block"。
to_block
(可选):获取交易的最大区块数。提供参数 "to_block" 或 "to_date" 如果提供了 "to_date" 和 "to_block",将使用 "to_block"。
offset
(可选):偏移量。
limit
(可选):限制。
marketplace
(可选):获取交易的市场(目前仅支持 opensea)。
address
(必填):合约地址(即 0x1a2b3x...)。你可以使用JS
、React
、curl
、Unity
来实现
const options = {
address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
limit: "10",
chain: "eth",
};
const NFTTrades = await Moralis.Web3API.token.getNFTTrades(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchNFTTrades = async () => {
const options = {
address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
limit: "10",
chain: "eth",
};
const NFTTrades = await Web3Api.token.getNFTTrades(options);
console.log(NFTTrades);
};
curl -X "GET"
"https://deep-index.moralis.io/api/v2/nft/0x7de3085b3190b3a787822ee16f23be010f5f8686/trades?chain=eth&marketplace=opensea"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchNFTTrades()
{
TradeCollection trades = await MoralisInterface.GetClient().Web3Api.Token.GetNFTTrades(address: "0x7de3085b3190b3a787822ee16f23be010f5f8686", ChainList.eth, limit: 10);
print(trades.ToJson());
}
示例结果
[
{
transaction_hash:
"0x4de0bcef1450492bd5c2e7693cf644c40005868d0dcc8a7a50a80ef2efa88d1e",
transaction_index: "164",
token_ids: ["16404"],
seller_address: "0xbae90f486d751f133702655627ce599249cd26b8",
buyer_address: "0x8795e90de359c1e0bf2579646486f7f12f270d2f",
token_address: "0xdf7952b35f24acf7fc0487d01c8d5690a60dba07",
marketplace_address: "0x7be8076f4ea4a4ad08075c2508e481d6c946d12b",
price: "280000000000000000",
price_token_address: null,
block_timestamp: "2021-05-09T23:00:25.000Z",
block_number: "7281522",
block_hash:
"0xe870c197b0c614e055f4de5b264bc7c69eafc93a6d0ce300309de444b2ff7e3a",
},
];
返回数据,包括给定合约地址的给定令牌 id 的完全解析的元数据(异步)。
选项:
chain
(可选):从中获取数据的区块链。 有效值列在支持的链上。 默认值 Eth。
format
(可选):token id 的格式。 可用值:十进制、十六进制。 默认值为十进制。
address
(必填): 合约地址
token_id
(必填):token的id你可以使用JS
、React
、curl
、Unity
来实现
const options = {
address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
token_id: "1",
chain: "eth",
};
const tokenIdMetadata = await Moralis.Web3API.token.getTokenIdMetadata(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchTokenIdMetadata = async () => {
const options = {
address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
token_id: "1",
chain: "eth",
};
const tokenIdMetadata = await Web3Api.token.getTokenIdMetadata(options);
console.log(tokenIdMetadata);
};
curl -X "GET"
"https://deep-index.moralis.io/api/v2/nft/0x7de3085b3190b3a787822ee16f23be010f5f8686/1?chain=eth&format=decimal"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchTokenIdMetadata()
{
Nft tokenIdMetadata = await MoralisInterface.GetClient().Web3Api.Token.GetTokenIdMetadata(address: "0x7de3085b3190b3a787822ee16f23be010f5f8686", tokenId: "1", ChainList.eth);
print(tokenIdMetadata.ToJson());
}
示例结果
{
token_address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
token_id: "1",
block_number_minted: "14238158",
owner_of: "0x324fb4a58674758e00c3a49409b815de1398bfe8",
block_number: "14238158",
amount: "1",
contract_type: "ERC721",
name: "Baby Ape Mutant Club",
symbol: "BAMC",
token_uri: "https://ipfs.moralis.io:2053/ipfs/QmYuHVS98nZxzYmuk9E6HA1TNr2W6PpV4fvE4MDfCFgfCP",
metadata: "{n "name": "Baby Ape Mutant Club",n "description": "Wait for reveal",n "image": "ipfs://QmPS5CMBd9Zwidies964iHb9hcdDmXZkWBGZyaJ9c1Gmif"n}n",
synced_at: "2022-02-19T18:50:43.217Z",
is_valid: 1,
syncing: 2,
frozen: 0
}
返回一个包含 NFT 传输次数的对象和一个包含给定合约集合中所有 NFT 项目所有者的数组(异步)。
选项:
chain
(可选):从中获取数据的区块链。 有效值列在支持的链上。 默认值 Eth。
format
(可选):token id 的格式。 可用值:十进制、十六进制。 默认值为十进制
offset
(可选):偏移量。
limit
(可选):限制。
address
(必填):合约地址。
token_id
(必填):token的id。你可以使用JS
、React
、curl
、Unity
来实现
const options = {
address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
token_id: "1",
chain: "eth",
};
const tokenIdOwners = await Moralis.Web3API.token.getTokenIdOwners(options);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchTokenIdOwners = async () => {
const options = {
address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
token_id: "1",
chain: "eth",
};
const tokenIdOwners = await Web3Api.token.getTokenIdOwners(options);
console.log(tokenIdOwners);
};
curl -X "GET"
"https://deep-index.moralis.io/api/v2/nft/0x7de3085b3190b3a787822ee16f23be010f5f8686/1/owners?chain=eth&format=decimal"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchTokenIdOwners()
{
NftOwnerCollection tokenIdOwners = await MoralisInterface.GetClient().Web3Api.Token.GetTokenIdOwners(address: "0x7de3085b3190b3a787822ee16f23be010f5f8686", tokenId: "1" , ChainList.eth);
print(tokenIdOwners.ToJson());
}
示例结果
[
{
token_address: "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
token_id: "15",
contract_type: "ERC721",
owner_of: "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
block_number: "88256",
block_number_minted: "88256",
token_uri: "string",
metadata: "string",
synced_at: "string",
amount: "1",
name: "CryptoKitties",
symbol: "RARI",
},
];
返回一个包含 NFT 传输次数的对象和一个包含所有 NFT 传输的数组(按令牌 ID(异步))。
选项:
chain
(可选):从中获取数据的区块链。 有效值列在支持的链上。 默认值 Eth。
format
(可选):token id 的格式。 可用值:十进制、十六进制。 默认值为十进制
offset
(可选):偏移量。
limit
(可选):限制。
address
(必填):合约地址。
token_id
(必填):token的id。你可以使用JS
、React
、curl
、Unity
来实现
const options = {
address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
token_id: "1",
chain: "eth",
};
const transfers = await Moralis.Web3API.token.getWalletTokenIdTransfers(
options
);
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";
const Web3Api = useMoralisWeb3Api();
const fetchWalletTokenIdTransfers = async () => {
const options = {
address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
token_id: "1",
chain: "eth",
};
const transfers = await Web3Api.token.getWalletTokenIdTransfers(options);
console.log(transfers);
};
curl -X "GET"
"https://deep-index.moralis.io/api/v2/nft/0x7de3085b3190b3a787822ee16f23be010f5f8686/1/transfers?chain=eth&format=decimal"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.Web3Api.Models;
using MoralisWeb3ApiSdk;
public async void fetchWalletTokenIdTransfers()
{
NftTransferCollection transfers = await MoralisInterface.GetClient().Web3Api.Token.GetWalletTokenIdTransfers(address: "0x7de3085b3190b3a787822ee16f23be010f5f8686", tokenId: "1", ChainList.eth);
print(transfers.ToJson());
}
示例结果
[
{
block_number: "14238158",
block_timestamp: "2022-02-19T18:49:02.000Z",
block_hash:
"0x8124f4a126996d306a90fa00b871b6ed9669a1a9806106b34fa28f3de61e5f8b",
transaction_hash:
"0x2db36892fc17bf99a3f6dd8a639f3c704f772858f3961cbcd26b3a42a2cd561e",
transaction_index: 162,
log_index: 419,
value: "0",
contract_type: "ERC721",
transaction_type: "Single",
token_address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
token_id: "1",
from_address: "0x0000000000000000000000000000000000000000",
to_address: "0x324fb4a58674758e00c3a49409b815de1398bfe8",
amount: "1",
verified: 1,
operator: null,
},
];
Moralis.Object在Moralis上存储数据是围绕Moralis.Object构建的。每个Moralis.Object都包含JSON兼容数据的键值对。此数...
此DO索引循环使用索引变量作为其开始和结束值。 重复执行SAS语句,直到达到索引变量的最终值。语法DO indexvariable= initialval...
线性回归用于识别因变量和一个或多个独立变量之间的关系。 提出了关系的模型,并且使用参数值的估计来形成估计的回归方程。 然后...
当需要针对智能穿戴开发低功耗应用时,推荐开发者使用深色主题模式。示例如下:开发注意事项智能穿戴电池容量有限,为了让应用对...
IdentityHashMapjava.lang.Object |---java.util.AbstractMapK,V |---|---java.util.IdentityHashMapK,Vpublic class IdentityHa...