Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Example Use Cases

Akhila Raju edited this page Jul 27, 2018 · 15 revisions

Information on a single block

Fetch all transactions from block 5000000 that have input data, and for those that can be decoded as token transfers, return the token symbol, sending and receiving addresses, as well as the token balance of the sending address. Fiddle with this query.

{
  block(number: 5000000) {
    hash
    transactions(filter: { withInput: true }) {
      index
      hash
      from {
        address
      }
      to {
        address
      }
      decoded {
        ... on ERC20Transfer {
          tokenContract {
            symbol
          }
          from {
            account {
                address
            }
            tokenBalance
          }
          to {
            account {
              address
            }
          }
          value
        }
      }
    }
  }
}

Information on specific blocks

Get the amount of gas expended in each transaction sent from address "0xF5bd64885c1330994Ca1E51c003916F3278A8bE9" in blocks 5942631, 5942640, 5927788, and 5441440. Fiddle with this query.

{
  blocks(numbers: [5942631, 5942640, 5927788, 5441440]) {
    transactionsRoles(from:"0xF5bd64885c1330994Ca1E51c003916F3278A8bE9") {
      gasPrice
    }
  }
}

Information on a range of blocks

For all blocks between 5400000 and 5400005 inclusive (6 blocks), get the balance of all addresses that sent a transaction. Fiddle with this query.

{
  blocksRange(numberRange: [5400000, 5400005]) {
    transactions {
      hash
      value
      from {
        address
        balance
      }
      to {
        address
      }
    }
  }
}

Information on an account

Reveal what is stored at Solidity Contract storage at index 0 for account "0x06012c8cf97BEaD5deAe237070F9587f8E7A266d". Fiddle with this query.

{
 account(address: "0x06012c8cf97BEaD5deAe237070F9587f8E7A266d"){
   storage{
     value(at: 0)
   }
 }
}

Information on a transaction

Fetch the log topics and attempt to decode the transaction to reveal event, entity, and standard information of transaction hash "0x7cc930cef131502bb78c13012caf0d99117892601b81fb95958aac98191fe6fb". Fiddle with this query.

{
  transaction(hash: "0x7cc930cef131502bb78c13012caf0d99117892601b81fb95958aac98191fe6fb") {
    logs {
      topics
      decoded {
        event
        entity
        standard
      }
    }
  }
}