# How to capture multiple token transfers within a single transaction?

**URL:** <https://community.bitquery.io/t/how-to-capture-multiple-token-transfers-within-a-single-transaction/1168>\
**Category:** GraphQL API\
**Created:** [August 12, 2022, 2:05pm UTC](https://community.bitquery.io/t/how-to-capture-multiple-token-transfers-within-a-single-transaction/1168 "2022-08-12T14:05:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheCoinCult](https://avatars.discourse-cdn.com/v4/letter/t/45deac/32.png) [@TheCoinCult](https://community.bitquery.io/u/TheCoinCult)\
**Post date:** [August 12, 2022, 2:05pm UTC](https://community.bitquery.io/t/how-to-capture-multiple-token-transfers-within-a-single-transaction/1168/1 "2022-08-12T14:05:38Z")

</div>

Hi, I have a paid subscription.

My program collects transaction data from your API using code similar to that below; it is intended to capture multiple transactions in a timeframe with txFrom and to address data for each transaction. Recently I have noticed that my query is producing unexpected results, because some transaction hashes are transferring multiple tokens and this code only captures the first token transfer in the list. In example, go to [Binance Transaction Hash (Txhash) Details | BscScan](https://bscscan.com/tx/0xddf971488500acb89d1c854ef02ecf6ec2f2f55d2258ede76bb91ca8f90d6725)

The code below records the txFrom as 0xf2f9b8ec0a8203a2cba497ffde4e75435f2db588 and the to as 0x7a62f3686bc633dd950d7c2c3ca3f2568f169b57.  
According to BSCscan, there are 6 tokens transfers listed within this transaction, whereas my code is only recording one of them.

How can I alter the code below in such a way that it records the from and to address, as well as token address and quantity, of each of these token transfers? Please bear in mind that I do not know how many tokens might be transferred in any txhash; this example shows 6, or it could be just 1, or any other quantity.

My current query:

```auto
{
      ethereum(network: bsc) {
        dexTrades(options: {limit: 10000, offset: 0, desc: "block.height"},
          time: { since: "2022-08-07T16:58:09z" , till: "2022-08-07T16:58:11z" }
          ) {
          tradeIndex
          transaction {
           hash
           txFrom {
            address
          }
           to {
            address
          }
          }
          block {
            height
            timestamp{
                  time(format: "%Y-%m-%d %H:%M:%S")
                }
          }
          buyAmount
          buyAmountInUsd: buyAmount(in: USD)
          buyCurrency {
            symbol
            address
          }
          sellAmount
            sellAmountInUsd: sellAmount(in: USD)
          sellCurrency {
            symbol
            address
          }
          sellAmountInUsd: sellAmount(in: USD)
          tradeAmount(in: USD)
    
        }
      }
    }

```

Thank you

---

<div class="post-metadata">

**Author:** ![gaurav](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@gaurav](https://community.bitquery.io/u/gaurav)\
**Post date:** [August 12, 2022, 7:29pm UTC](https://community.bitquery.io/t/how-to-capture-multiple-token-transfers-within-a-single-transaction/1168/2 "2022-08-12T19:29:30Z")

</div>

Token transfers and Dex trades are two different things.

For example the [txhash](https://explorer.bitquery.io/bsc/tx/0xddf971488500acb89d1c854ef02ecf6ec2f2f55d2258ede76bb91ca8f90d6725/dex_trades) you mentioned actually have 2 trades and [10 transfers](https://explorer.bitquery.io/bsc/tx/0xddf971488500acb89d1c854ef02ecf6ec2f2f55d2258ede76bb91ca8f90d6725/transfers)

The query you mentioned above shows 2 trades (search for tx hash in the result, and you will see two trades)… now if you want all transfers for tx hash. then use transfer API like this [trasnfers for tx hash](https://graphql.bitquery.io/ide/trasnfers-for-tx-hash)

---

<div class="post-metadata">

**Author:** ![TheCoinCult](https://avatars.discourse-cdn.com/v4/letter/t/45deac/32.png) [@TheCoinCult](https://community.bitquery.io/u/TheCoinCult)\
**Post date:** [August 12, 2022, 8:19pm UTC](https://community.bitquery.io/t/how-to-capture-multiple-token-transfers-within-a-single-transaction/1168/3 "2022-08-12T20:19:00Z")

</div>

OK, your example does provide the information I want, however is there a way to retrieve that for every txHash within a timeframe on BSC, similar to how my code grabs all txHash within a timeframe?

So I would provide a time since:, till: and get back a list similar to:  
{  
hash: \_\_\_  
time:\_\_\_\_  
transfers:[  
{  
sender:  
address:\_\_\_\_  
receiver:  
address:\_\_\_\_  
amount:\_\_\_  
amount\_usd:\_\_\_\_  
currency:  
symbol:\_\_\_\_  
address:\_\_\_\_  
},{  
(next transfer, if exists)  
}  
]  
},{  
hash:\_\_\_\_  
etc

I hope this is clear. I’m trying to grab all of the txHash and token transfers within a timeframe.

Thank you.

---

<div class="post-metadata">

**Author:** ![gaurav](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@gaurav](https://community.bitquery.io/u/gaurav)\
**Post date:** [August 16, 2022, 7:32am UTC](https://community.bitquery.io/t/how-to-capture-multiple-token-transfers-within-a-single-transaction/1168/4 "2022-08-16T07:32:09Z")

</div>

> [@gaurav](#):
>
> trasnfers for tx hash

Please try this [Transfers in time range](https://graphql.bitquery.io/ide/Transfers-in-time-range)
