---
# System prepended metadata

title: 'BitQuery:'

---

# BitQuery: 




------
# 1: Transactions, Senders 
- Daily Txs
- Daily Active Address
- Daily Gas Cost 
```
query ($network: EthereumNetwork!,
  $dateFormat: String!,
  $from: ISO8601DateTime,
  $till: ISO8601DateTime) {
  ethereum(network: $network) {
    transactions(
      options: {desc: "date.date"}, 
      date: {since: $from, till: $till})
    {
      date: date {
        date(format: $dateFormat)
      }
    	gasValue
      gasValueAvg: gasValue(calculate: average)
      gasPrice
      avgGasPrice: gasPrice(calculate:average)
      medGasPrice: gasPrice(calculate: median)
      maxGasPrice: gasPrice(calculate: maximum)
      Txs: count
      Senders: count(uniq:senders)
    }
  }
}
```
Q.V
```
{"network":"ethereum",
  "from":"2020-09-01",
  "till":null,
  "dateFormat":"%Y-%m-%d"}
  ```
:::success
- 交易次數
- 活躍地址數數
- 消耗瓦斯費
:::
  
# 2: Token Contract Txs via ContractCalls
- Daily Token Txs calls


```
query (
  $network: EthereumNetwork!,
  $address: [String!], 
  $from: ISO8601DateTime, 
  $till: ISO8601DateTime
) {
  ethereum(network: $network) {
    smartContractCalls(
      options: {desc: "date.date"}, 
      date: {since: $from, till: $till}, 
      smartContractAddress: {in: $address}
    ) 
    {
      date: date {
        date
      }
      smartContract{
        currency{
          symbol
        }
      }
      externalCalls: count(external: true)
      internalCalls: count(external: false)
      Count: count
      callers: count(uniq: callers)
      txs: count(uniq: txs)
    }
  }
}
```
```
{"network":"bsc",
  "from":"2020-10-01",
  "till":null,
  "address":[
    "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",  #WBNB
    "0xe9e7cea3dedca5984780bafc599bd69add087d56",
    "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",
    "0x55d398326f99059ff775485246999027b3197955",
    "0x2170ed0880ac9a755fd29b2688956bd959f933f8",
    "0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c",
    "0x7083609fce4d1d8dc0c979aab8c869ea2c873402",
    "0xf8a0bf9cf54bb92f17374d9e9a321e6a111a51bd",
    "0xcf6bb5389c92bdda8a3747ddb454cb7a64626c63",
    "0x47bead2563dcbf3bf2c9407fea4dc236faba485a"
  ]
}
```

:::success
- smartContractCall: 的幾種方式
- 
:::
#### 2-1: Contract Call 
當天的合約smartContractCalls, Senders
```
query ($network: EthereumNetwork!,
  #$address: [String!], 
  $from: ISO8601DateTime, 
  $till: ISO8601DateTime) {
  ethereum(network: $network) {
    ## Contract Call 有局限性
    smartContractCalls(
      options: {desc: "totalCount"}, 
      date: {since: $from, till: $till}, 
      #smartContractAddress: {in: $address}
    ) 
    {
      date: date {
        date(format: "%Y-%m-%d %H")
      }
      smartContract{
        address{
          address
        }
        currency{
          symbol
        }
      }
      externalCalls: count(external: true)
      internalCalls: count(external: false)
      totalCount: count
      senders: count(uniq:senders) 
      callers: count(uniq: callers)
      Txs: count(uniq: txs)
    }
  }
}
```
```
{"network":"bsc",
  "from":"2020-10-18",
  "till":"2020-10-18"
}
```




------
# 0: Active Address & Txs 
- SmartContractCall: Senders & Txs
``` GraphQL
#### SmartContractCall: Senders & Txs
query ($dateFormat: String!
  , $from: ISO8601DateTime
  , $till: ISO8601DateTime) 
  {
  ethereum(network:bsc) {
    smartContractCalls(
      options: {desc: "date.date"}
      , date: {since: $from, till: $till}
    ) {
      date {
        date(format: $dateFormat)
      }
      ## amount 
      external_calls: count(external: true) 
      internal_calls: count(external: false)
      external_callers: count(uniq: callers, external: true)
      internal_callers: count(uniq: callers, external: false)
      senders: count(uniq: senders)
      txs: count(uniq: txs)
    }
  }
}
`````
QV
````
{  "from":null,
  "till":null,
  "dateFormat":"%Y-%m-%d"
}
````





### 3: 合約消耗瓦斯數
* **smartContractCalls**
``` 
query($dateFormat: String!){
  ethereum(network: bsc) {
    smartContractCalls(
      options: {desc: "date.date"}, 
      date: {since: "2020-10-01", till: "2020-10-15"}, 
      external: true)
    { 
      date {
        date(format: $dateFormat)
      }
      ##### Measure 
      MedGas: gasValue(calculate: median)
      AvgGas: gasValue(calculate: average)
      MaxGas: gasValue(calculate:maximum)
      SumGas: gasValue(calculate: sum)
      Txs_Times:count 
    }
  }
}
```
QV
```
{  "dateFormat":"%Y-%m-%d"}
```

* Transaction




----- 