On this page

latest contributor to this doc

Last Edit:

@gcharang

Query NFT database tables

After using the update_nft method to initialise your local NFT database, the following tables are available in DB/KOMODEFI.db:

  • AVAX_nft_list
  • AVAX_nft_transfer_history
  • BNB_nft_list
  • BNB_nft_transfer_history
  • ETH_nft_list
  • ETH_nft_transfer_history
  • FTM_nft_list
  • FTM_nft_transfer_history
  • MATIC_nft_list
  • MATIC_nft_transfer_history
  • scanned_nft_blocks

The COIN_nft_list tables contain the NFTs that you own It has the following columns, though not all columns are populated for all NFTs:

IDNameTypeDescription
0token_addressVARCHAR(256)The address of the token contract.
1token_idVARCHAR(256)The id of the token.
2chainTEXTThe coin network which the NFT is on.
3amountVARCHAR(256)The amount of NFTs transfered in this transaction.
4block_numberINTEGERThe block height of this transaction.
5contract_typeTEXTThe contract type. Either ERC721 or ERC1155.
6possible_spamINTEGER1 indicates the NFT has been identified as spam. 0 indicates it has not.
7possible_phishingINTEGER1 indicates the NFT has been identified as a scam. 0 indicates it has not.
8collection_nameTEXTThe collection name which includes the token.
9symbolTEXTAn arbitrary symbol for the NFT
10token_uriTEXTA link to the token's metadata.
11token_domainTEXTThe domain the token metadata is hosted on.
12metadataTEXTThe token's metadata in JSON format.
13last_token_uri_syncTEXTDate and time when the token uri was last syncronised.
14last_metadata_syncTEXTDate and time when the token metadata was last syncronised.
15raw_image_urlTEXTThe raw URL for the token image.
16image_urlTEXTA link for the token's image (or other media).
17image_domainTEXTThe domain the token image (or other media) is hosted on.
18token_nameTEXTThe name of the token.
19descriptionTEXTAn arbitrary description of the NFT.
20attributesTEXTAdditional attribute data for the NFT in JSON format.
21animation_urlTEXTIf NFT is animated, the URL of the animation.
22animation_domainTEXTIf NFT is animated, the domain of the animation.
23external_urlTEXTAdditional URL related to the NFT
24external_domainTEXTDomain of the additional URL related to the NFT
25image_detailsTEXTAdditional details about the NFT's image.
26details_jsonTEXTAdditional information about the transaction in JSON format.

SELECT chain, token_name, token_address, token_id, possible_spam, possible_phishing FROM MATIC_nft_list LIMIT 5;

chaintoken_nametoken_addresstoken_idpossible_spampossible_phishing
POLYGON$2000 USDT Airdrop🎁0xe7ee9dcf5f4b7f9254b348ba596c9fb9121f77e7110
POLYGON$1000 USDC Voucher🎁0xb092b5eb5c653e915880dfc1f606be2ffe6fae8c110
POLYGON1000 BLUR Reward0xeaa3c52052b809c8d8072187efc134def2dd5b13010
POLYGONSHIB Voucher 66 of 1000xc46e36339ebd8bed48b1bdb6bd815e4b72103949010
POLYGON$1000 Rewards0x6e0b84421388ad635f2a1167e39aff2dc742da2a010

The NFTs listed above are all spam, and will be ignored by the get_nft_list method.

The COIN_nft_transfer_history tables contain the history of transfers of your NFTs, and have the following columns:

IDNameTypeDescription
0transaction_hashVARCHAR(256)Hex string, representing the transaction.
1log_indexINTEGERSimply a table index.
2chainTEXTThe coin network which the NFT is on.
3block_numberINTEGERThe block height of this transaction.
4block_timestampINTEGERThe block time of this transaction.
5contract_typeTEXTThe contract type. Either ERC721 or ERC1155.
6token_addressVARCHAR(256)The address of the token contract.
7token_idVARCHAR(256)The id of the token.
8statusTEXTThe transaction type: Recieve or Send
9amountVARCHAR(256)The amount of NFTs transfered in this transaction.
10possible_spamINTEGER1 indicates the NFT has been identified as spam. 0 indicates it has not.
11possible_phishingINTEGER1 indicates the NFT has been identified as a scam. 0 indicates it has not.
12token_uriTEXTA link to the token's metadata.
13token_domainTEXTThe domain the token metadata is hosted on.
14collection_nameTEXTThe collection name which includes the token.
15image_urlTEXTA link for the token's image (or other media).
16image_domainTEXTThe domain the token image (or other media) is hosted on.
17token_nameTEXTThe name of the token.
18details_jsonTEXTAdditional information about the transaction in JSON format.

SELECT transaction_hash, token_name, token_address, token_id, FROM MATIC_nft_transfer_history WHERE block_timestamp > 1701519320;

transaction_hashtoken_nametoken_addresstoken_id
0x7b57303bcc2c68808b460490e984adcd18567a80660a18b7a151b62015247cda$2000 USDT Airdrop🎁0xe7ee9dcf5f4b7f9254b348ba596c9fb9121f77e71

The scanned_nft_blocks table contains the last block that was scanned for each chain. It has the following columns:

IDNameTypeDescription
2chainTEXTThe coin network which the NFT is on.
1last_scanned_blockINTEGERThe block height when the last scan for NFTs was performed on a chain.

SELECT * FROM scanned_nft_blocks;

chainlast_scanned_block
MATIC50651981
FTM66512090
ETH0
BNB0
AVAX0