How to get all NFT transfers by wallet
Step 1: Setup Moralis
Read the article Setting Up Moralis: Getting Started and make sure to finish all the steps. Only after that you can go ahead to complete this guide.
Step 2: Get all NFT transfers by wallet
In order to get all NFT transfers by wallet, Moralis provides you with an getWalletNFTTransfers endpoint.
Here you'll need two parameters: address
and chain
.
Once you have obtained the address
and chain
, you can copy the following code:
- index.js (JavaScript)
- index.ts (TypeScript)
- index.py (Python)
const Moralis = require("moralis").default;
const { EvmChain } = require("@moralisweb3/common-evm-utils");
const runApp = async () => {
await Moralis.start({
apiKey: "YOUR_API_KEY",
// ...and any other configuration
});
const address = "0xd8da6bf26964af9d7eed9e03e53415d37aa96045";
const chain = EvmChain.ETHEREUM;
const response = await Moralis.EvmApi.nft.getWalletNFTTransfers({
address,
chain,
});
console.log(response.toJSON());
};
runApp();
import Moralis from "moralis";
import { EvmChain } from "@moralisweb3/common-evm-utils";
const runApp = async () => {
await Moralis.start({
apiKey: "YOUR_API_KEY",
// ...and any other configuration
});
const address = "0xd8da6bf26964af9d7eed9e03e53415d37aa96045";
const chain = EvmChain.ETHEREUM;
const response = await Moralis.EvmApi.nft.getWalletNFTTransfers({
address,
chain,
});
console.log(response.toJSON());
};
runApp();
from moralis import evm_api
api_key = "YOUR_API_KEY"
params = {
"address": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
"chain": "eth"
}
result = evm_api.nft.get_wallet_nft_transfers(
api_key=api_key,
params=params,
)
print(result)
Step 3: Run the script
To run the script, enter the following command:
- Shell (JavaScript)
- Shell (TypeScript)
- Shell (Python)
node index.js
ts-node index.ts
python index.py
In your terminal, you should see the following 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": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
"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 just got all NFT transfers by wallet with just a few lines of code using the Moralis Wallet API!
API Reference
If you want to know more details on the endpoint and optional parameters, check out:
Support
If you face any trouble following the tutorial, feel free to reach out to our community engineers in our Discord or Forum to get 24/7 developer support.