Changes in token approvals for ERC721 contracts

Chains supported: Ethereum, Base, Arbitrum (post Nitro)

🟦

Block-level table

For efficiency, we only emit one record per block for each (token_address, token_id) pair. If there are 2+ changes for the same pair in a given block, we emit the last one. This more efficiently serves queries where you want to know state after a given block, but precludes queries that need intra-block (i.e., transaction-level) state.

Schema

Column NameData Type
chain_idlong
txn_hashstring
block_numberlong
block_timestamplong
token_addressstring
token_namestring
token_symbolstring
ownerstring
token_address_owner_hashstring
is_for_allbool
token_idbigDecimal
token_address_id_hashstring
approved_addressstring
operatoraddress
approvedbool

Source

This table was built in sim's ERC721 Owner Changes Block canvas.

Usage notes

There are two types of approvals for ERC721:

  1. approve(address to, uint256 tokenId) grants permission to a single address to transfer a specific NFT, identified by its ID. Approve records will have is_for_all = false and the details of the approval specified in token_id and approved_address. The two remaining columns, operator and approved, take default values and should be disregarded for this case.
  2. setApprovalForAll(address operator, bool approved) grants or revokes permission to an operator address to manage all of the caller's NFTs. In this case, is_for_all = true and the operator is defined in operator. If approved = true then the record corresponds to the granting of an approval. If approved = false, the record corresponds to the removal of an approval.

This column contains two composite index columns to improve performance for queries:

  1. token_address_owner_hash is the keccak256 hash (token_address, owner). Use in queries where you would otherwise filter on (token_address, owner).
  2. token_address_id_hash is the keccak256 hash (token_address, token_id). Use in queries where you would otherwise filter on (token_address, token_id).

Sample queries

getERC721ApprovalsForOwner