๐ŸŽด
Web3API.token

getTokenMetadata

Returns metadata (name, symbol, decimals, logo) for a given token contract address (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
  • addresses (required): The address or an array of addresses to get metadata for
JS
React
curl
Unity
1
//Get metadata for one token. Ex: USDT token on ETH
2
const options = {
3
chain: "eth",
4
addresses: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
5
};
6
const tokenMetadata = await Moralis.Web3API.token.getTokenMetadata(options);
7
โ€‹
8
//Get metadata for an array of tokens. Ex: USDT and USDC tokens on BSC
9
const options = {
10
chain: "bsc",
11
addresses: [
12
"0x55d398326f99059ff775485246999027b3197955",
13
"0x0a385f86059e0b2a048171d78afd1f38558121f3",
14
],
15
};
16
const tokenMetadata = await Moralis.Web3API.token.getTokenMetadata(options);
Copied!
1
import React from "react";
2
import { useMoralisWeb3Api } from "react-moralis";
3
โ€‹
4
const Web3Api = useMoralisWeb3Api();
5
โ€‹
6
const fetchTokenMetadata = async () => {
7
//Get metadata for one token. Ex: USDT token on ETH
8
const options = {
9
chain: "eth",
10
addresses: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
11
};
12
const tokenMetadata = await Web3Api.token.getTokenMetadata(options);
13
console.log(tokenMetadata);
14
โ€‹
15
//Get metadata for an array of tokens. Ex: USDT and USDC tokens on BSC
16
const options = {
17
chain: "bsc",
18
addresses: [
19
"0x55d398326f99059ff775485246999027b3197955",
20
"0x0a385f86059e0b2a048171d78afd1f38558121f3",
21
],
22
};
23
const tokenArrayMetadata = await Web3Api.token.getTokenMetadata(options);
24
console.log(tokenArrayMetadata);
25
};
Copied!
1
curl -X 'GET' \
2
'https://deep-index.moralis.io/api/v2/erc20/metadata?chain=bsc&addresses=0x55d398326f99059ff775485246999027b3197955&addresses=0x0a385f86059e0b2a048171d78afd1f38558121f3' \
3
-H 'accept: application/json' \
4
-H 'X-API-Key: MY-API-KEY'
Copied!
1
using MoralisUnity;
2
using MoralisUnity.Web3Api.Models;
3
using System.Collections.Generic;
4
using UnityEngine;
5
โ€‹
6
public class Example
7
{
8
public async void fetchTokenMetadata()
9
{
10
List<string> addresses = new List<string>();
11
addresses.Add("0xdAC17F958D2ee523a2206206994597C13D831ec7");
12
addresses.Add("0x0a385f86059e0b2a048171d78afd1f38558121f3");
13
List<Erc20Metadata> resp = await Moralis.Web3Api.Token.GetTokenMetadata(addresses, ChainList.eth);
14
foreach (Erc20Metadata erc20metadata in resp)
15
{
16
Debug.Log(erc20metadata.ToJson());
17
}
18
}
19
}
Copied!

Example result:

1
[
2
{
3
address: "0x0a385f86059e0b2a048171d78afd1f38558121f3",
4
name: "USD Coin on BSC",
5
symbol: "USDC",
6
logo: null,
7
logo_hash: null,
8
thumbnail: null,
9
decimals: "6",
10
block_number: "8242108",
11
validated: 1,
12
created_at: "2022-01-20T10:41:03.034Z",
13
},
14
{
15
address: "0x55d398326f99059ff775485246999027b3197955",
16
name: "Tether USD",
17
symbol: "USDT",
18
logo: null,
19
logo_hash: null,
20
thumbnail: null,
21
decimals: "18",
22
block_number: "8242108",
23
validated: 1,
24
created_at: "2022-01-20T10:41:03.034Z",
25
},
26
];
Copied!

getTokenMetadataBySymbol

Returns metadata (name, address, decimals, logo) for given symbols (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
  • symbols (required): The token symbol or an array of symbols to get metadata for
JS
React
curl
Unity
1
//Get metadata for one token
2
const options = { chain: "bsc", symbols: "LINK" };
3
const tokenMetadata = await Moralis.Web3API.token.getTokenMetadataBySymbol(
4
options
5
);
6
โ€‹
7
//Get metadata for an array of tokens
8
const options = { chain: "bsc", symbols: ["LINK", "AAVE"] };
9
const tokenMetadata = await Moralis.Web3API.token.getTokenMetadataBySymbol(
10
options
11
);
Copied!
1
import React from "react";
2
import { useMoralisWeb3Api } from "react-moralis";
3
โ€‹
4
const Web3Api = useMoralisWeb3Api();
5
โ€‹
6
const fetchTokenMetadataBySymbol = async () => {
7
//Get metadata for one token
8
const options = { chain: "bsc", symbols: "LINK" };
9
const tokenMetadata = await Web3Api.token.getTokenMetadataBySymbol(options);
10
console.log(tokenMetadata);
11
โ€‹
12
//Get metadata for an array of tokens
13
const options = { chain: "bsc", symbols: ["LINK", "AAVE"] };
14
const tokenArrayMetadata = await Web3Api.token.getTokenMetadataBySymbol(
15
options
16
);
17
console.log(tokenArrayMetadata);
18
};
Copied!
1
curl -X 'GET' \
2
'https://deep-index.moralis.io/api/v2/erc20/metadata/symbols?chain=bsc&symbols=LINK&symbols=AAVE' \
3
-H 'accept: application/json' \
4
-H 'X-API-Key: MY-API-KEY'
Copied!
1
using MoralisUnity;
2
using MoralisUnity.Web3Api.Models;
3
using System.Collections.Generic;
4
using UnityEngine;
5
โ€‹
6
public class Example
7
{
8
โ€‹
9
public async void fetchTokenMetadataBySymbol()
10
{
11
List<string> symbols = new List<string>();
12
symbols.Add("AAVE");
13
symbols.Add("LINK");
14
List<Erc20Metadata> resp = await Moralis.Web3Api.Token.GetTokenMetadataBySymbol(symbols, ChainList.bsc);
15
foreach (Erc20Metadata erc20metadata in resp)
16
{
17
Debug.Log(erc20metadata.ToJson());
18
}
19
}
20
}
Copied!

Example result:

1
[
2
{
3
address:
4
"0x2d30ca6f024dbc1307ac8a1a44ca27de6f797ec22ef20627a1307243b0ab7d09",
5
name: "Kylin Network",
6
symbol: "KYL",
7
decimals: "18",
8
logo: "https://cdn.moralis.io/eth/0x67b6d479c7bb412c54e03dca8e1bc6740ce6b99c.png",
9
logo_hash:
10
"ee7aa2cdf100649a3521a082116258e862e6971261a39b5cd4e4354fcccbc54d",
11
thumbnail:
12
"https://cdn.moralis.io/eth/0x67b6d479c7bb412c54e03dca8e1bc6740ce6b99c_thumb.png",
13
block_number: "string",
14
validated: "string",
15
},
16
];
Copied!

getTokenAllowance

Returns the amount which the spender is allowed to withdraw from the spender (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
  • owner_address (required): The address of the token owner
  • spender_address (required): The address of the token spender
  • address(required): The address of the token contract
JS
React
curl
Unity
1
//Get token allowace on ETH
2
const options = {
3
//token holder
4
owner_address: "0xd1628228ffaede220cd583da5f9262355682210a",
5
//uniswap v3 router 2 contract address
6
spender_address: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
7
//ENS token contract address
8
address: "0xC18360217D8F7Ab5e7c516566761Ea12Ce7F9D72",
9
};
10
const allowance = await Moralis.Web3API.token.getTokenAllowance(options);
Copied!
1
import React from "react";
2
import { useMoralisWeb3Api } from "react-moralis";
3
โ€‹
4
const Web3Api = useMoralisWeb3Api();
5
โ€‹
6
const fetchTokenAllowance = async () => {
7
//Get token allowace on ETH
8
const options = {
9
//token holder
10
owner_address: "0xd1628228ffaede220cd583da5f9262355682210a",
11
//uniswap v3 router 2 contract address
12
spender_address: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
13
//ENS token contract address
14
address: "0xC18360217D8F7Ab5e7c516566761Ea12Ce7F9D72",
15
};
16
const allowance = await Web3Api.token.getTokenAllowance(options);
17
console.log(allowance);
18
};
Copied!
1
curl -X 'GET' \
2
'https://deep-index.moralis.io/api/v2/erc20/0xC18360217D8F7Ab5e7c516566761Ea12Ce7F9D72/allowance?chain=eth&owner_address=0xd1628228ffaede220cd583da5f9262355682210a&spender_address=0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45' \
3
-H 'accept: application/json' \
4
-H 'X-API-Key: MY-API-KEY'
Copied!
1
using MoralisUnity;
2
using MoralisUnity.Web3Api.Models;
3
using UnityEngine;
4
โ€‹
5
public class Example
6
{
7
public async void fetchTokenMetadataBySymbol()
8
{
9
Erc20Allowance allowance = await Moralis.Web3Api.Token.GetTokenAllowance(address: "0xC18360217D8F7Ab5e7c516566761Ea12Ce7F9D72", ownerAddress: "0xd1628228ffaede220cd583da5f9262355682210a", spenderAddress: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", ChainList.eth);
10
Debug.Log(allowance.ToJson());
11
}
12
}
Copied!

Example result:

1
{
2
"allowance": "115792089237316195423570985008687907853269984665640564039457584007913129639935"
3
}
Copied!

getTokenPrice

Returns the price nominated in the native token and usd for a given token contract address (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
  • exchange(optional): The factory name or address of the token exchange. Possible exchanges, for different chains are: ETH mainnet: uniswap-v3, sushiswap, uniswap-v2 BSC mainnet: pancakeswap-v2, pancakeswap-v1 Polygon mainnet: quickswap If no exchange is specified, all exchanges are checked (in the order as listed above) until a valid pool has been found. Note that this request can take more time. So specifying the exchange will result in faster responses most of the time.
  • address(required): The address of the token contract
  • to_block(optional): Returns the price for a given blocknumber (historical price-data)
JS
React
curl
1
//Get token price on PancakeSwap v2 BSC
2
const options = {
3
address: "0x42F6f551ae042cBe50C739158b4f0CAC0Edb9096",
4
chain: "bsc",
5
exchange: "PancakeSwapv2",
6
};
7
const price = await Moralis.Web3API.token.getTokenPrice(options);
Copied!
1
import React from "react";
2
import { useMoralisWeb3Api } from "react-moralis";
3
โ€‹
4
const Web3Api = useMoralisWeb3Api();
5
โ€‹
6
const fetchTokenPrice = async () => {
7
//Get token price on PancakeSwap v2 BSC
8
const options = {
9
address: "0x42F6f551ae042cBe50C739158b4f0CAC0Edb9096",
10
chain: "bsc",
11
exchange: "PancakeSwapv2",
12
};
13
const price = await Web3Api.token.getTokenPrice(options);
14
console.log(price);
15
};
Copied!
1
curl -X 'GET' \
2
'https://deep-index.moralis.io/api/v2/erc20/0x42F6f551ae042cBe50C739158b4f0CAC0Edb9096/price?chain=bsc&exchange=PancakeSwapv2' \
3
-H 'accept: application/json' \
4
-H 'X-API-Key: MY-API-KEY'
Copied!

Example result:

1
{
2
"nativePrice": {
3
"value": "8409770570506626",
4
"decimals": 18,
5
"name": "Ether",
6
"symbol": "ETH"
7
},
8
"usdPrice": 19.722370676,
9
"exchangeAddress": "0x1f98431c8ad98523631ae4a59f267346ea31f984",
10
"exchangeName": "Uniswap v3"
11
}
Copied!

getAllTokenIds

Returns an object with a number of NFTs and an array with NFT metadata (name, symbol) for a given token contract address (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
  • format (optional): The format of the token id. Available values : decimal, hex. Default value : decimal.
  • offset (optional): offset.
  • limit(optional): limit.
  • address(required): The address of the token contract.
JS
React
curl
Unity
1
const options = {
2
address: "0x7dE3085b3190B3a787822Ee16F23be010f5F8686",
3
chain: "eth",
4
};
5
const NFTs = await Moralis.Web3API.token.getAllTokenIds(options);
Copied!
1
import React from "react";
2
import { useMoralisWeb3Api } from "react-moralis";
3
โ€‹
4
const Web3Api = useMoralisWeb3Api();
5
โ€‹
6
const fetchAllTokenIds = async () => {
7
const options = {
8
address: "0x7dE3085b3190B3a787822Ee16F23be010f5F8686",
9
chain: "eth",
10
};
11
const NFTs = await Web3Api.token.getAllTokenIds(options);
12
console.log(NFTs);
13
};
Copied!
1
curl -X 'GET' \
2
'https://deep-index.moralis.io/api/v2/nft/0x7dE3085b3190B3a787822Ee16F23be010f5F8686?chain=eth&format=decimal' \
3
-H 'accept: application/json' \
4
-H 'X-API-Key: MY-API-KEY'
Copied!
1
using MoralisUnity;
2
using MoralisUnity.Web3Api.Models;
3
using UnityEngine;
4
โ€‹
5
public class Example
6
{
7
public async void fetchAllTokenIds()
8
{
9
NftCollection nfts = await Moralis.Web3Api.Token.GetAllTokenIds(address: "0x7dE3085b3190B3a787822Ee16F23be010f5F8686", ChainList.eth);
10
Debug.Log(nfts.ToJson());
11
}
12
}
Copied!

Example result:

1
[
2
{
3
token_address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
4
token_id: "728",
5
amount: "1",
6
contract_type: "ERC721",
7
name: "Baby Ape Mutant Club",
8
symbol: "BAMC",
9
token_uri:
10
"https://gateway.moralisipfs.com/ipfs/QmajSqgxY3cWBgBeRm38vasJAcTit1kp5EwqVHxszJYgUC/728.json",
11
metadata:
12
'{\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}',
13
synced_at: "2022-03-05T02:29:18.441Z",
14
},
15
];
Copied!

getNFTMetadata

Returns the contract level metadata (name, symbol, base token uri) for the given contract (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
  • address(required): The address of the token contract.
JS
React
curl
Unity
1
const options = {
2
address: "0x7dE3085b3190B3a787822Ee16F23be010f5F8686",
3
chain: "eth",
4
};
5
const metaData = await Moralis.Web3API.token.getNFTMetadata(options);
Copied!
1
import React from "react";
2
import { useMoralisWeb3Api } from "react-moralis";
3
โ€‹
4
const Web3Api = useMoralisWeb3Api();
5
โ€‹
6
const fetchNFTMetadata = async () => {
7
const options = {
8
address: "0x7dE3085b3190B3a787822Ee16F23be010f5F8686",
9
chain: "eth",
10
};
11
const metaData = await Web3Api.token.getNFTMetadata(options);
12
console.log(metaData);
13
};
Copied!
1
curl -X 'GET' \
2
'https://deep-index.moralis.io/api/v2/nft/0x7dE3085b3190B3a787822Ee16F23be010f5F8686/metadata?chain=eth' \
3
-H 'accept: application/json' \
4
-H 'X-API-Key: MY-API-KEY'
Copied!
1
using MoralisUnity;
2
using MoralisUnity.Web3Api.Models;
3
using UnityEngine;
4
โ€‹
5
public class Example
6
{
7
public async void fetchNFTMetadata()
8
{
9
NftContractMetadata metadata = await Moralis.Web3Api.Token.GetNFTMetadata(address: "0x7dE3085b3190B3a787822Ee16F23be010f5F8686", ChainList.eth);
10
Debug.Log(metadata.ToJson());
11
}
12
}
Copied!
Requests for contract addresses not yet indexed will automatically start the indexing process for that NFT collection

Example result:

1
{
2
"token_address": "0x7de3085b3190b3a787822ee16f23be010f5f8686",
3
"name": "Baby Ape Mutant Club",
4
"symbol": "BAMC",
5
"contract_type": "ERC721",
6
"synced_at": "2022-02-19"
7
}
Copied!

getNFTOwners

Returns an object with a number of NFT owners and an array with NFT metadata (name, symbol) for a given token contract address (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
  • format (optional): The format of the token id. Available values : decimal, hex. Default value : decimal.
  • offset (optional): offset.
  • limit(optional): limit.
  • address(required): Address of the contract
JS
React
curl
Unity
1
const options = {
2
address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
3
chain: "eth",
4
};
5
const nftOwners = await Moralis.Web3API.token.getNFTOwners(options);
Copied!
1
import React from "react";
2
import { useMoralisWeb3Api } from "react-moralis";
3
โ€‹
4
const Web3Api = useMoralisWeb3Api();
5
โ€‹
6
const fetchNFTOwners = async () => {
7
const options = {
8
address: "0x7de3085b3190b3a787822ee16f23be010f5f8686",
9
chain: "eth",
10
};
11
const nftOwners = await Web3Api.token.getNFTOwners(options);
12
console.log(nftOwners);
13
};
Copied!
1
curl -X 'GET' \
2
'https://deep-index.moralis.io/api/v2/nft/0x7de3085b3190b3a787822ee16f23be010f5f8686/owners?chain=eth&format=decimal' \
3
-H 'accept: application/json' \
4
-H 'X-API-Key: MY-API-KEY'
Copied!
1
using MoralisUnity;
2
using MoralisUnity.Web3Api.Models;
3
using UnityEngine;
4
โ€‹
5
public class Example
6
{
7
public async void fetchNFTOwners()
8
{
9
NftOwnerCollection nftowners = await Moralis.Web3Api.Token.GetNFTOwners(address: "0x7de3085b3190b3a787822ee16f23be010f5f8686", ChainList.eth);
10
Debug.Log(nftowners.ToJson());
11
}
12
}
Copied!
Make sure to include a sort parm on a column like token_id for consistent pagination results
Requests for contract addresses not yet indexed will automatically start the indexing process for that NFT collection

Example result:

1
[
2
{
3
token_address: "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
4
token_id: "15",
5
contract_type: "ERC721",
6
owner_of: "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
7
block_number: "88256",
8
block_number_minted: "88256",
9
token_uri: "string",
10
metadata: "string",
11
synced_at: "string",
12
amount: "1",
13
name: "CryptoKitties",
14
symbol: "RARI",
15
},
16
];
Copied!

getNftTransfersFromToBlock

Gets NFT transfers from a block number to a block number

Options:

Needs at least one of from_block, to_block , from_date , to_date
  • chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
  • from_block(optional): The minimum block number from where to get the transfers. Provide the param 'from_block' or 'from_date'. If 'from_date' and 'from_block' are provided, 'from_block' will be used.
  • to_block (optional): The maximum block number from where to get the transfers. Provide the param 'to_block' or 'to_date', If 'to_date' and 'to_block' are provided, 'to_block' will be used.
  • from_date (optional): The date from where to get the transfers (any format that is accepted by momentjs). Provide the param 'from_block' or 'from_date'. If 'from_date' and 'from_block' are provided, 'from_block' will be used.
  • to_date(optional): Get transfers up until this date (any format that is accepted by momentjs). Provide the param 'to_block' or 'to_date'. If 'to_date' and 'to_block' are provided, 'to_block' will be used.
  • format(optional): The format of the token id. Available values : decimal, hex. Default value : decimal.
  • limit(optional): limit
JS
React
curl
Unity
1
const options = {
2
from_block: "14876000",
3
to_block: "14877000",
4
//from_date: "",
5
//to_date: "",
6
format: "decimal",
7
limit: "10",
8
};
9
const data = await Moralis.Web3API.token.getNftTransfersFromToBlock(options);
Copied!
1
import React from "react";
2
import { useMoralisWeb3Api } from "react-moralis";
3
โ€‹
4
const Web3Api = useMoralisWeb3Api();
5
โ€‹
6
const nftTransfers = async () => {
7
const options = {
8
from_block: "14876000",
9
to_block: "14877000",
10
format: "decimal",
11
limit: "10",
12
};
13
const nftTransfers = await Web3Api.token.getNftTransfersFromToBlock(options);
14
console.log(nftTransfers);
15
};
Copied!
1
curl -X 'GET' \
2
'https://deep-index.moralis.io/api/v2/nft/transfers?chain=eth&from_block=14876000&format=decimal' \
3
-H 'accept: application/json' \
4
-H 'X-API-Key: MY-API-KEY'
Copied!
1
using MoralisUnity;
2
using MoralisUnity.Web3Api.Models;
3
using UnityEngine;
4
โ€‹
5
public class Example
6
{
7
public async void fetchNFTTransfers()
8
{
9
NftTransferCollection nftTransfers = await Moralis.Web3Api.Token.getNftTransfersFromToBlock(from_block: "14876000", ChainList.eth);
10
Debug.Log(nftTransfers.ToJson());
11
}
12
}
Copied!
Make sure to include a sort parm on a column like token_id for consistent pagination results
Requests for contract addresses not yet indexed will automatically start the indexing process for that NFT collection

Example result:

1
"result": [
2
{
3
"block_number": "14876001",
4
"block_timestamp": "2022-05-31T01:41:33.000Z",
5
"block_hash": "0x38e7a69058a46376774dfe7f625e0cca7828a129925ada09ab7761bda6b701de",
6
"transaction_hash": "0x0ec413e59b7ca4d0eee2c18ae054315b30faed0c3ddb5de6af0689794f225abe",
7
"transaction_index": 180,
8
"log_index": 416,
9
"value": "24900000000000000",
10
"contract_type": "ERC721",
11
"transaction_type": "Single",
12
"token_address": "0x415f77738147a65a9d76bb0407af206a921cee0f",
13
"token_id": "1377",
14
"from_address": "0xcc3490aecec5eb123c2f6a51e406f04debb47f96",
15
"to_address": "0xe966275f1e1932fb064f9ba90aa65e0c2ad0bfad",
16
"amount": "1",
17
"verified": 1,
18
"operator": null
19
},
20
{
21
"block_number": "14876001",
22
"block_timestamp": "2022-05-31T01:41:33.000Z",
23
"block_hash": "0x38e7a69058a46376774dfe7f625e0cca7828a129925ada09ab7761bda6b701de",
24
"transaction_hash": "0x7de568004f40c193989306e2e3bb3c17670c2aef7da2fb5065b633d6cd48bd1b",
25
"transaction_index": 178,
26
"log_index": 413,
27
"value": "80000000000000000",
28
"contract_type": "ERC1155",
29
"transaction_type": "Single",
30
"token_address": "0xb66a603f4cfe17e3d27b87a8bfcad319856518b8",
31
"token_id": "68508210689022796360004252200345882845300391813826407755322269495475862241291",
32
"from_address": "0x977645ec9a66cb8baa744c73862b7525845390ec",
33
"to_address": "0x0ee8951fe70b088b5ecf63af4491ed230bbd51a6",
34
"amount": "1",
35
"verified": 1,
36
"operator": "0x5cf4ce4bcd9c49c153e644f11d3fed7a64ccc065"
37
},
38
];
Copied!

searchNFTs

Very powerful and fast tool for getting the NFT data based on a metadata search (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
  • format (optional): The format of the token id. Available values : decimal, hex. Default value : decimal.
  • offset (optional): offset.
  • limit(optional): limit.
  • q (required): The search string parameter
  • filter(required): What fields the search should match on. To look into the entire metadata set the value to global. To have a better response time you can look into a specific field like name. Available values : name; description; attributes; global; name,description; name,attributes; description,attributes; name,description,attributes
JS
React
curl
Unity
1
const options = { q: "Pancake", chain: "bsc", filter: "name" };
2
const NFTs = await Moralis.Web3API.token.searchNFTs(options);
Copied!
1
import React from "react";
2
import { useMoralisWeb3Api } from "react-moralis";
3
โ€‹
4
const Web3Api = useMoralisWeb3Api();
5
โ€‹
6
const fetchSearchNFTs = async () => {
7
const options = { q: "Pancake", chain: "bsc", filter: "name" };
8
const NFTs = await Web3Api.token.searchNFTs(options);
9
console.log(NFTs);
10
};
Copied!
1
curl -X 'GET' \
2
'https://deep-index.moralis.io/api/v2/nft/search?chain=bsc&format=decimal&q=Pancake&filter=name' \
3
-H 'accept: application/json' \
4
-H 'X-API-Key: MY-API-KEY'
Copied!
1
using MoralisUnity;
2
using MoralisUnity.Web3Api.Models;
3
using UnityEngine;
4
โ€‹
5
public class Example
6
{
7
public async void fetchSearchNFTs()
8
{
9
NftMetadataCollection nft = await Moralis.Web3Api.Token.SearchNFTs(q: "Pancake", ChainList.bsc, filter: "name");
10
Debug.Log(nft.ToJson());
11
}
12
}
Copied!

Example result:

1
[
2
{
3
token_id: "124436",
4
token_address: "0x3afa102b264b5f79ce80fed29e0724f922ba57c7",
5
token_uri:
6
"https://ipfs.moralis.io:2053/ipfs/QmVAD8v4s2SXF8FgjePqMdQ2GV5hE2isZnzxcrA36XcSDA/metadata.json",
7
metadata:
8
'{"name":"Pancake","description":"The dessert series 1","image":"ipfs://QmNQFXCZ6LGzvpMW9Q5PWbCrEnLknQrPwr2r8pbQAgzQ9A/4863BD6B-6C92-4B96-BF80-8020B2F7C3A5.jpeg"}',
9
contract_type: "ERC721",
10
token_hash: "d03fe436e972bf9215d7bb8c64c4c556",
11
synced_at: null,
12
created_at: "2021-09-19T10:36:16.610Z",
13
},
14
];
Copied!

Searching by global:

JS
React
curl
Unity
1
const options = { q: "bored ape", chain: "bsc", filter: "global" };
2
const NFTs = await Moralis.Web3API.token.searchNFTs(options);
Copied!
1
import React from "react";
2
import { useMoralisWeb3Api } from "react-moralis";
3
โ€‹
4
const Web3Api = useMoralisWeb3Api();
5
โ€‹
6
const fetchSearchNFTs = async () => {
7
const options = { q: "bored ape", chain: "bsc", filter: "global" };
8
const NFTs = await Web3Api.token.searchNFTs(options);
9
console.log(NFTs);
10
};
Copied!
1
curl -X 'GET' \
2
'https://deep-index.moralis.io/api/v2/nft/search?chain=bsc&format=decimal&q=Pancake&filter=global' \
3
-H 'accept: application/json' \
4
-H 'X-API-Key: MY-API-KEY'
Copied!
1
using MoralisUnity;
2
using MoralisUnity.Web3Api.Models;
3
using UnityEngine;
4
โ€‹
5
public class Example
6
{
7
public async void fetchSearchNFTs()
8
{
9
NftMetadataCollection nft = await Moralis.Web3Api.Token.SearchNFTs(q: "Pancake", ChainList.bsc, filter: "global");
10
Debug.Log(nft.ToJson());
11
}
12
}
Copied!

Searching by description,attributes:

JS
React
curl
Unity
1
const options = {
2
q: "loves bananas",
3
chain: "bsc",
4
filter: "description,attributes",
5
};
6
const NFTs = await Moralis.Web3API.token.searchNFTs(options);
Copied!
1
import React from "react";
2
import { useMoralisWeb3Api } from "react-moralis";
3
โ€‹
4
const Web3Api = useMoralisWeb3Api();
5
โ€‹
6
const fetchSearchNFTs = async () => {
7
const options = {
8
q: "loves bananas",
9
chain: "bsc",
10
filter: "description,attributes",
11
};
12
const NFTs = await Web3Api.token.searchNFTs(options);
13
console.log(NFTs);
14
};
Copied!
1
curl -X 'GET' \
2
'https://deep-index.moralis.io/api/v2/nft/search?chain=bsc&format=decimal&q=Pancake&filter=description%2Cattributes' \
3
-H 'accept: application/json' \
4
-H 'X-API-Key: MY-API-KEY'
Copied!
1
using MoralisUnity;
2
using MoralisUnity.Web3Api.Models;
3
using UnityEngine;
4
โ€‹
5
public class Example
6
{
7
public async void fetchSearchNFTs()
8
{
9
NftMetadataCollection nft = await Moralis.Web3Api.Token.SearchNFTs(q: "Pancake", ChainList.bsc, filter: "description,attributes");
10
Debug.Log(nft.ToJson());
11
}
12
}
Copied!

getContractNFTTransfers

Returns an object with number of NFT transfers and an array with NFT transfers for a given token contract address (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
  • format (optional): The format of the token id. Available values : decimal, hex. Default value is decimal.