Links

nft_balance

Gets the balance for the given account address.
Through nft_balance, you can fetch how many NFTs that the account owns in that collection, contractAddress and accountAddress are necessary. Balance means the amount of NFTs in a collection. This API could be used to see specific account's NFT possession.
Supported on Ethereum, BNB Chain, Optimism, and Arbitrum.

Parameters

Object - An object with the following fields (required):
  • contractAddress(hex string, required) - the contract address of the collection. BlockVision currently support both ERC721 and ERC1155.
  • accountAddress(hex string, required) - the account address you want to query.
  • tokenId(string, optional) - id of the NFT. optional for ERC721. required for ERC1155.
  • blockNumber(integer number, optional) - specify the blockNumber for snapshot query (default latest). BlockVision can not only support users to query the current position, but also support users to query the historical information at any time.

Returns

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:
    • value(string) - balance value.
    • accountAddress(hex string) - account address which mint the collection.
    • contractAddress(hex string) - contract of address of the collection.
    • blockNumber(integer number) - the NFT is mint in this block.

Example

Request

curl
TypeScript
curl https://api.blockvision.org/v1/<api key> \
-X POST \
-H "Content-Type: application/json" \
-d '{
"id": 1,
"jsonrpc": "2.0",
"method": "nft_balance",
"params": {
"contractAddress":"0xad9Fd7cB4fC7A0fBCE08d64068f60CbDE22Ed34C",
"accountAddress":"0xC4B0D0A7717905d342926958453e0654806850bB",
"blockNumber": 0
}
}'
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.getNFTBalance({
contractAddress: '0xad9Fd7cB4fC7A0fBCE08d64068f60CbDE22Ed34C',
accountAddress: '0xC4B0D0A7717905d342926958453e0654806850bB',
blockNumber: 0
}).then(console.log)

Result

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"contractAddress": "0xad9Fd7cB4fC7A0fBCE08d64068f60CbDE22Ed34C",
"accountAddress": "0xC4B0D0A7717905d342926958453e0654806850bB",
"blockNumber": 13687883,
"value": "0"
}
}