All Token Transfers

Leveraging our open source functions, you can readily get token transfers across any of the networks we support. Here’s how simple it is to get all token transfers:
function tokenTransfers(block) {
  return templates.token_transfers(block);
}
This will return transfers matching the following type:
type NetworkTransfer = {
  amount: number | bigint;
  blockNumber: number;
  from: string;
  index?: string;
  timestamp: string;
  to: string;
  token?: string;
  tokenId?: string;
  tokenType: 'NATIVE' | 'TOKEN' | 'NFT';
  transactionGasFee: bigint;
  transactionHash: string;
};
Here’s a sample request for testing this against Polygon:
curl "https://app.indexing.co/dw/transformations/test?network=polygon&beat=74046461" \
  -H 'X-API-KEY: <API_KEY>' \
  -H 'Content-Type: application/json' \
  -d '{
    "code": "function(block) { return templates.token_transfers(block); }"
  }' | jq

Filtered Transfers

Notably, the above output includes a tokenType key. You can leverage this to focus in on particular token types that might be useful. For instance, this is how you could fetch only NFT transfers:
function tokenTransfers(block) {
  return templates
    .token_transfers(block)
    .filter(txfer => txfer.tokenType === 'NFT');
}