nft_approvals
Get historical events for NFT approval at any address without scanning the entire chain.
Through nft_approvals, you can fetch all the approval events happening in specified contract,
contractAddress
is necessary. If you specify the contract address and account address, the API will return all the approval events of that collection which the account address has.Supported on Ethereum, BNB Chain, Optimism, and Arbitrum.
Object
- An object with the following fields (required):contractAddress(hex string, optional)
- the contract address of the collection. BlockVision currently support both ERC721 and ERC1155.accountAddress(hex string, optional)
- the account address you want to query.fromBlockNumber(integer number, optional)
- the starting time range you want to fetch events over.toBlockNumber(integer number, optional)
- the ending time range you want to fetch events over.fromAddress(hex string, optional)
- the sending address in the transaction.toAddress(hex string, optional)
- the receiving address in the transaction.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:nextPageIndex(integer number)
- next page index.data(array of object, defined below)
- response data, sorted in ascending order by block number.
- Object schema:
blockNumber(integer number)
- the block where the transfer occurred.txHash(hex string)
- transaction hash.blockHash(hex string)
- block hash.logIndex(integer number)
- event index.tokeID(string)
- id of the NFT.contractAddress(hex string)
- contract address.approved(hex string)
- approved address.owner(hex string)
- owner address.
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_approvals",
"params": {
"fromBlockNumber": 0,
"toBlockNumber": 0,
"toAddress":"",
"contractAddress":"0xad9Fd7cB4fC7A0fBCE08d64068f60CbDE22Ed34C",
"pageSize": 2,
"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.getNFTApprovals({}).then(console.log)
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"data": [
{
"tokenID": "5828",
"contractAddress": "0xad9Fd7cB4fC7A0fBCE08d64068f60CbDE22Ed34C",
"blockNumber": 13950629,
"txHash": "0x96979a2e64a214bc9feed6f73934728035c19c43da2b4922f03405e619da81db",
"blockHash": "0x186d9447b1188bf88a78ebe15e322e044bc566337ea8e5bbcafdc93e9b868128",
"logIndex": 86,
"owner": "0x5bD8C88109B0680fF8EE0481716dC1AAedDC7D07",
"approved": "0x0000000000000000000000000000000000000000"
},
{
"tokenID": "8156",
"contractAddress": "0xad9Fd7cB4fC7A0fBCE08d64068f60CbDE22Ed34C",
"blockNumber": 13950606,
"txHash": "0x2f67c7713daf8253dfe955fbdcad610d84f12b530b14f087343371a83a572614",
"blockHash": "0xdab19dc8c7fecde2c2df6736101cf68a74c8854ca2eb656b23e2acf131ecca67",
"logIndex": 23,
"owner": "0x6a9D009f2b7b4D2F655858f828fe7B4105814832",
"approved": "0x0000000000000000000000000000000000000000"
}
],
"nextPageIndex": 2
}
}
Last modified 1mo ago