Skip to main content

Don't have an API key yet?

Sign-up to Moralis to get your free API key and start building today.

Get Your Free API Key
Version: 2.2

How to Get NFT Transfers of a Smart Account

tip

If you'd like examples of account types, read the Ethereum Accounts article.

Gaining access to the historical transfer data of a non-fungible token (NFT) opens up a world of possibilities for developers. This data provides a comprehensive and transparent record of an NFT's journey through various smart contracts, showcasing crucial information such as previous owners, sale prices, and the exact moments of a transfer. And the Moralis Wallet API offers a convenient solution to retrieve all transfers of an NFT efficiently.

This step-by-step tutorial shows how to easily track, retrieve, and query NFT transfers in a smart account using an account address and token contract. What's more, the tutorial includes multiple code examples in various programming languages.

tip

This tutorial uses Moralis' getWalletNFTTransfers RPC method.

Step 1: Set Up Moralis

Read our Setting Up Moralis: Getting Started article and finish all of its steps. Only after that can you go ahead to complete this guide.

Step 2: Method to Get and Retrieve NFT transfers for a Given Smart Account Address

To transfer an NFT to another user, the current owner initiates the transfer process. This typically involves interacting with the NFT smart contract and specifying the recipient's wallet address. The transfer request is then broadcast to the blockchain network.

You can use the getWalletNFTTransfers API endpoint to get all transactions for an address of a smart account. Moreover, this endpoint allows you to fetch transactions for a given address of a smart account.

You will need two essential parameters:

  • address
  • chain

Once you have obtained both address and chain, you can use the code snippets below to retrieve the transactions:

// Import necessary libraries and modules
const Moralis = require("moralis").default;
const { EvmChain } = require("@moralisweb3/common-evm-utils");

// Define an asynchronous function to run the application
const runApp = async () => {
// Initialize Moralis with your API key and configuration
await Moralis.start({
apiKey: "YOUR_API_KEY",
// ...other configuration options
});

// Define the Ethereum address you want to query NFT transfers for
const address = "0x350845DD3f03F1355233a3A7CEBC24b5aAD05eC5";

// Specify the Ethereum chain (in this case, ETHEREUM)
const chain = EvmChain.ETHEREUM;

// Retrieve NFT transfer data using Moralis' EvmApi
const response = await Moralis.EvmApi.nft.getWalletNFTTransfers({
address,
chain,
});

// Output the JSON response to the console
console.log(response.toJSON());
};

// Execute the runApp function
runApp();

Step 3: Run the Script

To run the script, enter the following command:

node index.js

Code example of the JSON response:

{
"total": null,
"page": 0,
"page_size": 100,
"cursor": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcmRlciI6IkRFU0MiLCJvZmZzZXQiOjAsImxpbWl0IjoxMDAsImRpc2FibGVfdG90YWwiOnRydWUsIndoZXJlIjp7fSwiZnJvbV9hZGRyZXNzIjoiMHhkOGRhNmJmMjY5NjRhZjlkN2VlZDllMDNlNTM0MTVkMzdhYTk2MDQ1IiwidG9fYWRkcmVzcyI6IjB4ZDhkYTZiZjI2OTY0YWY5ZDdlZWQ5ZTAzZTUzNDE1ZDM3YWE5NjA0NSIsInBhZ2UiOjEsImtleSI6IjE3NDMzNDI5LjUzLjEzMy4wIiwidG90YWwiOm51bGwsImlhdCI6MTY4OTc1ODUzNH0.MIBO5T05EbJruMe_ywWXEs99WJZ4jabI5IciWQugpYE",
"result": [
{
"block_number": "17715655",
"block_timestamp": "2023-07-17T21:27:59.000Z",
"block_hash": "0x58f8652ecb7025849a740fe0d6d270c61f9d0d59b41ab6460f4d9d6bb292b80d",
"transaction_hash": "0xf5e701f9f16f66ec8cdd3fa9f5c52b15410188392a0ffc128777bb89b2c73243",
"transaction_index": 80,
"log_index": 225,
"value": "0",
"contract_type": "ERC1155",
"transaction_type": "Single",
"token_address": "0xd4416b13d2b3a9abae7acd5d6c2bbdbe25686401",
"token_id": "32861001645432232115677216693187330961962340035243999304845689030250465478890",
"from_address": "0x26fcbd3afebbe28d0a8684f790c48368d21665b5",
"from_address_label": null,
"to_address": "0xea97bb00daa1880e0a575b38e723066a398595ea",
"to_address_label": null,
"amount": "1",
"verified": 1,
"operator": "0x11be6670e94c6862dcd92bd4c27753f4df50890d",
"possible_spam": false,
"verified_collection": true
},
// ....
]
}

Congratulations! 🥳 You have successfully fetched NFT transfers for a given smart account address on Ethereum using the Moralis Wallet API.

Video Tutorial: Get All NFT Transfers by a Contract Address

For a visual guide, you can check out our YouTube tutorial:

Get 24/7 Developer Support

Should you encounter any challenges while following this tutorial, our community engineers are here to assist you. Reach out to us on Discord or our Moralis forum to receive 24/7 developer support. Your success is our priority!

API Reference

If you want to explore more details about other wallet endpoints and optional parameters, check out our API Reference page.

See Also