Returns the owner for a given ERC721 token
Parameters
chain_id
(uint64, default: 1)token_address
(address as hex string, default: 0x45ebb5fe718f40052fb2dc2463c13717b7b72768)- The token address for which we want to check its owner.
token_id
(int256 as decimal string, default: 4811)- The token id for which we want to check its owner.
block_number
(uint64, default: 0)- Optional. Can be used to view owner at a particular block. If unset, defaults to
0
and returns latest.
- Optional. Can be used to view owner at a particular block. If unset, defaults to
Returns
owner
(address as hex string)
Query
SELECT b.owner
FROM @sim.erc721_owner_changes_block b
WHERE b.token_address = lower($token_address)
AND b.chain_id = $chain_id
AND b.token_id = $token_id
AND b.block_number IN (
SELECT MAX(block_number) AS latest_block_number
FROM @sim.erc721_owner_changes_block
WHERE token_address = lower($token_address)
AND chain_id = $chain_id
AND token_id = $token_id
AND (
block_number <= $block_number
OR $block_number = 0
)
)