# Query for address contacted with a smart contract

**URL:** <https://community.bitquery.io/t/query-for-address-contacted-with-a-smart-contract/494>\
**Category:** GraphQL API\
**Tags:** closed\
**Created:** [September 18, 2021, 7:36pm UTC](https://community.bitquery.io/t/query-for-address-contacted-with-a-smart-contract/494 "2021-09-18T19:36:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hackingwithutkarsh](https://avatars.discourse-cdn.com/v4/letter/h/e99b99/32.png) [@hackingwithutkarsh](https://community.bitquery.io/u/hackingwithutkarsh)\
**Post date:** [September 18, 2021, 7:36pm UTC](https://community.bitquery.io/t/query-for-address-contacted-with-a-smart-contract/494/1 "2021-09-18T19:36:08Z")

</div>

{  
ethereum(network: bsc\_testnet) {  
smartContractCalls(  
caller: {is: “0x0e8492d5566365236f0E179fd6956fe87c6AC3EB”}  
smartContractAddress: {is: “0x2d4ee064ebb491b1e6db6ea1962db59d1d0e0741”}

```
) {
  block {
    timestamp {
      time(format: "%Y-%m-%d %H:%M:%S")
    }
    height
  }
  smartContractMethod {
    name
    signatureHash
  }
  address: caller {
    address
    annotation
  }
  transaction {
    hash
  }
  gasValue
  external
}

```

}  
}

This query gives output of txn hash and various other information of each txn. What can I add so we can also get the amount of each token traded in each txn as it showing other information for each txn. I want to get all this information from this query only. How can I do that?

---

<div class="post-metadata">

**Author:** ![sayon](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sayon](https://community.bitquery.io/u/sayon)\
**Post date:** [September 20, 2021, 5:07am UTC](https://community.bitquery.io/t/query-for-address-contacted-with-a-smart-contract/494/2 "2021-09-20T05:07:31Z")

</div>

You can do that by adding the **amount** field in your GraphQL query

```auto
{
  ethereum(network: bsc_testnet) {
    smartContractCalls(
      caller: {is: "0x0e8492d5566365236f0E179fd6956fe87c6AC3EB"}
      smartContractAddress: {is: "0x2d4ee064ebb491b1e6db6ea1962db59d1d0e0741"}
    ) {
      block {
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
        height
      }
      smartContractMethod {
        name
        signatureHash
      }
      address: caller {
        address
        annotation
      }
      transaction {
        hash
      }
      gasValue
      external
      amount(in: USD)
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![hackingwithutkarsh](https://avatars.discourse-cdn.com/v4/letter/h/e99b99/32.png) [@hackingwithutkarsh](https://community.bitquery.io/u/hackingwithutkarsh)\
**Post date:** [September 20, 2021, 5:57am UTC](https://community.bitquery.io/t/query-for-address-contacted-with-a-smart-contract/494/3 "2021-09-20T05:57:57Z")

</div>

That will just show the USD value of gas used not the tokens traded

---

<div class="post-metadata">

**Author:** ![sayon](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sayon](https://community.bitquery.io/u/sayon)\
**Post date:** [September 20, 2021, 5:59am UTC](https://community.bitquery.io/t/query-for-address-contacted-with-a-smart-contract/494/4 "2021-09-20T05:59:37Z")

</div>

I guess in order to get the gas value, the **gasValue** field comes into play. I guess adding a **count** field with unique transactions should do the work

```auto
{
  ethereum(network: bsc_testnet) {
    smartContractCalls(
      caller: {is: "0x0e8492d5566365236f0E179fd6956fe87c6AC3EB"}
      smartContractAddress: {is: "0x2d4ee064ebb491b1e6db6ea1962db59d1d0e0741"}
    ) {
      block {
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
        height
      }
      smartContractMethod {
        name
        signatureHash
      }
      address: caller {
        address
        annotation
      }
      transaction {
        hash
      }
      gasValue
      external
      count(uniq: txs)
    }
  }
}

```

---

<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:** [October 13, 2021, 2:30pm UTC](https://community.bitquery.io/t/query-for-address-contacted-with-a-smart-contract/494/5 "2021-10-13T14:30:32Z")

</div>

For getting DEX trade related data, you need to use DEXTRADES API

For example.

```auto
{
  ethereum(network: bsc_testnet) {
    dexTrades(
      txSender: {is: "0x0e8492d5566365236f0e179fd6956fe87c6ac3eb"}
    ) {
      transaction {
        hash
      }
      smartContract {
        address {
          address
        }
        contractType
        currency {
          name
        }
      }
      tradeIndex
      date {
        date
      }
      block {
        height
      }
      buyAmount
      buyAmountInUsd: buyAmount(in: USD)
      buyCurrency {
        symbol
        address
      }
      sellAmount
      sellAmountInUsd: sellAmount(in: USD)
      sellCurrency {
        symbol
        address
      }
      sellAmountInUsd: sellAmount(in: USD)
      tradeAmount(in: USD)
      transaction {
        gasValue
        gasPrice
        gas
      }
    }
  }
}

```
