nft_accountOwnedOrRentTokenIDs
Get all owned or renting NFTs for an account address without scanning the entire chain.
Through nft_accountOwnedOrRentTokenIDs, you can fetch all the data of NFTs that an account owns or rents,
accountAddress
is necessary. You can clearly know what NFTs a holder owns or rents. Some use cases could call this API such as accurate airdrop.Supported on Ethereum and BNB Chain.
Object
- An object with the following fields (required):accountAddress(hex string, required)
- the account address you want to query.contractAddress(hex string, optional)
- the contract address of the collection. BlockVision currently support ERC721, ERC1155 and ERC4907.pageSize(integer number, optional, default 20 max 50)
- max number of results to return per call.pageIndex(integer number, optional, default 1)
- page index.
Object
- An object with the following fields:id(integer number)
- json-rpc id.jsonrpc(string)
- json-rpc version.result(object)
- an object with the following fields:ownedList(array of object, defined below)
- list of NFTs owned.rentList(array of object, defined below)
- list of NFTs renting.total(integer number)
- Total number of NFTs.
- Object schema:
tokenId(string)
- id of the NFT.contractAddress(hex string)
- contract address of the NFT.quantity(string)
- quantity of the NFT.standard(string)
- ERC standard for NFT, The enumeration value is erc721, erc1155, erc4907, or "".expires(integer number)
- UNIX timestamp, The new user could use the NFT before expires.
curl
TypeScript
curl https://apis.blockvision.org/v1/<api key> \
-X POST \
-H "Content-Type: application/json" \
-d '{
"id": 1,
"jsonrpc": "2.0",
"method": "nft_accountOwnedOrRentTokenIDs",
"params": {
"contractAddress": "",
"accountAddress": "0xfc06cc834874c6d424b6ebf4a7a48042daa2d267",
"pageSize": 20,
"pageIndex": 1
}
}'
import { BlockVisionProvider, BvNetwork } from 'blockvision.js'
// Optional parameters, but default to eth-mainnet and default api-key.
const bv = new BlockVisionProvider(BvNetwork.ETH_MAINNET)
// Access the BlockVision NFT API
bv.getNFTAccountOwnedOrRentTokenIDs({
accountAddress: '0xfc06cc834874c6d424b6ebf4a7a48042daa2d267'
}).then(console.log)
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"ownedList": [
{
"contractAddress": "0x01E690c5D3cc89cea84F2a3C2CcB38410Ce2992D",
"tokenId": "4914",
"quantity": 1,
"standard": "erc721"
},
{
"contractAddress": "0x02e2993C180C219Da15f2a6cCD2A334797C13263",
"tokenId": "3337",
"quantity": 1,
"standard": "erc721"
},
{
"contractAddress": "0x03b008EeD21889fcd29e76b4D8f89394A1FC1497",
"tokenId": "7909",
"quantity": 1,
"standard": "erc721"
}
],
"rentList": [
{
"contractAddress": "0x2b41eF782A3064993f8BAA368a8D14d82443fdA9",
"tokenId": "44",
"quantity": 1,
"standard": "ERC4907",
"expires": 1668068999
},
{
"contractAddress": "0x29e0A58F62A34a29965ac5c64f5F3c792bEe7A9a",
"tokenId": "43",
"quantity": 1,
"standard": "ERC4907",
"expires": 1668039239
}
],
"total": 672
}
}
Last modified 3mo ago