---
# System prepended metadata

title: ethVM graphql endpoints
tags: [ideas]

---

---
tags: ideas
---

# ethVM graphql endpoints

## Address
Overview

```plain
query getEthBalance($hash: String!) {
    getEthBalance(owner: $hash) {
        balance
    }
}

query getContractMeta($hash: String!) {
    getContractMeta(contract: $hash) {
      block,
      codeHash,
      creator,
      transactionHash
    }
}

query getContractTimestamp($hash: String!) {
    getTransactionByHash(hash: $hash) {
        timestamp
    }
}
```

  

Address pending tx

```plain
query getPendingTransactions($hash: String!) {
    getPendingTransactions(owner: $hash) {
        from
        to
        timestamp
        value
        gas
        gasPrice
        hash
    }
}

subscription pendingTransaction($owner: String!) {
    pendingTransaction(owner: $owner) {
        transactionHash
        txFee
        from
        to
        timestamp
        value
    }
}

subscription pendingMined($hash: String!) {
    transactionEvent(hash: $hash)
}
```

  

Address rewards

```plain
fragment BalanceFragment on BalanceDiff {
    before
    after
}

fragment RewardSummary on ETHTransfers {
    transfers {
        transfer {
            block
            timestamp
            txFee
        }
        stateDiff {
            to {
                ...BalanceFragment
            }
            from {
                ...BalanceFragment
            }
        }
        value
    }
    nextKey
}

query getAddrRewardsBlock($hash: String!, $_limit: Int, $_nextKey: String) {
    getBlockRewards(owner: $hash, limit: $_limit, nextKey: $_nextKey) {
        ...RewardSummary
    }
}

query getAddrRewardsUncle($hash: String!, $_limit: Int, $_nextKey: String) {
    getUncleRewards(owner: $hash, limit: $_limit, nextKey: $_nextKey) {
        ...RewardSummary
    }
}

query getAddrRewardsGenesis($hash: String!, $_limit: Int, $_nextKey: String) {
    getGenesisRewards(owner: $hash, limit: $_limit, nextKey: $_nextKey) {
        ...RewardSummary
    }
}

query getBlockUncleRewards($blockRef: Int!) {
    getBlockByNumber(number: $blockRef) {
        summary {
            rewards {
                uncles
            }
        }
    }
}
```

  

Address tokens

```plain
fragment TokenFragment on EthTokenInfo {
    name
    symbol
    decimals
}

query getOwnersERC20Tokens($hash: String!, $_nextKey: String) {
    getOwnersERC20Tokens(owner: $hash, nextKey: $_nextKey) {
        owners {
            tokenInfo {
                ...TokenFragment
                contract
            }
            balance
        }
        nextKey
    }
}

query getOwnersERC721Balances($hash: String!) {
    getOwnersERC721Balances(owner: $hash) {
        balance
        tokenInfo {
            name
            symbol
            contract
        }
    }
}

query getOwnersERC721Tokens($hash: String!, $tokenContract: String, $_nextKey: String) {
    getOwnersERC721Tokens(owner: $hash, contract: $tokenContract, nextKey: $_nextKey) {
        tokens {
            token
        }
        nextKey
    }
}

query getNFTcontractsMeta($address: String!) {
```

```undefined
    getNFTcontractsMeta(address: $address) @rest(type: "AddressNFTcontracts", path: "/nft?{args}") {
        tokenContracts @type(name: "NFTContract") {
            contractIdAddress
            owned_asset_count
            name
            contractImage
            primary_asset_contracts @type(name: "PrimaryAssetContract") {
                address
                name
                symbol
                total_supply
                description
                external_link
                image_url
            }
```

```plain
        }
```

```undefined
    }
}
```

  

Address transfers

```plain
fragment TransferSummary on Transfer {
    transactionHash
    timestamp
    from
    to
    txFee
}
fragment TokenFragment on EthTokenInfo {
    name
    symbol
    decimals
}

fragment BalanceFragment on BalanceDiff {
    before
    after
}

query getAddressEthTransfers($hash: String, $filter: TransferFilter, $_limit: Int, $_nextKey: String) {
    getEthTransfersV2(owner: $hash, filter: $filter, limit: $_limit, nextKey: $_nextKey) {
        transfers {
            transfer {
                ...TransferSummary
                block
                status
            }
            stateDiff {
                to {
                    ...BalanceFragment
                }
                from {
                    ...BalanceFragment
                }
            }
            value
        }
        nextKey
    }
}

query getAddressERC20Transfers($hash: String!, $_limit: Int, $_nextKey: String) {
    getERC20Transfers(owner: $hash, limit: $_limit, nextKey: $_nextKey) {
        transfers {
            transfer {
                ...TransferSummary
            }
            stateDiff {
                to {
                    ...BalanceFragment
                }
                from {
                    ...BalanceFragment
                }
            }
            value
            contract
            tokenInfo {
                ...TokenFragment
            }
        }
        nextKey
    }
}

query getAddressERC721Transfers($hash: String!, $_limit: Int, $_nextKey: String) {
    getERC721Transfers(owner: $hash, limit: $_limit, nextKey: $_nextKey) {
        transfers {
            transfer {
                ...TransferSummary
            }
            token
            contract
            tokenInfo {
                name
            }
        }
        nextKey
    }
}


query getTransactionStateDiff($hash: String!){
    getTransactionStateDiff(hash: $hash) {
        owner
        from
        to
    }
}
```

  

Address update event

```plain
subscription addressEvent($owner: String!, $event: AddressEventType) {
    addressEvent(owner: $owner, event: $event) {
        blockNumber
        event
        timestamp
        owner
    }
}
```

  

Blocks
------

Block details

```plain
fragment BlockDetails on Block {
    summary {
        number
        miner
        txCount
        timestamp
        uncles
        rewards {
            txFees
            total
            uncles
        }
        txFail
    }
    hash
    parentHash
    nonce
    sha3Uncles
    logsBloom
    transactionsRoot
    stateRoot
    receiptsRoot
    difficulty
    totalDifficulty
    extraData
    size
    gasLimit
    gasUsed
    transactions
}

query getBlockByNumber($blockRef: Int!) {
    getBlockByNumber(number: $blockRef) {
        ...BlockDetails
    }
}

query getBlockByHash($blockRef: String!) {
    getBlockByHash(hash: $blockRef) {
        ...BlockDetails
    }
}

query getLastBlockNumber {
    getLatestBlockInfo {
        number
    }
}
```

  

Block stats

```plain
query getLatestBlockInfo {
    getLatestBlockInfo {
        number
        avgBlockTime
        hashRate
        difficulty
    }
}
```

  

Recent blocks

```plain
query getBlocksArrayByNumber($fromBlock: Int, $limit: Int) {
    getBlocksArrayByNumber(fromBlock: $fromBlock, limit: $limit) {
        number
        miner
        txCount
        timestamp
        rewards {
            total
        }
        txFail
    }
}
subscription newBlockTable {
    newBlockFeed {
        number
        miner
        txCount
        timestamp
        rewards {
            total
        }
    }
}
```

  

Tokens
------

Token details

```plain
fragment TokenDetails on EthTokenInfo {
  name
  symbol
  decimals
  totalSupply
  contract
}

fragment ERC20TokenOwnerDetails on ERC20TokenBalance  {
  tokenInfo {
    ...TokenDetails
  }
  owner
  balance
}

query getTokenInfoByContract($contract: String!) {
  getTokenInfoByContract(contract: $contract) {
    ...TokenDetails
  }
} 

query getERC20TokenBalance($contract: String!, $owner: String!) {
  getERC20TokenBalance(contract: $contract, owner: $owner) {
    ...ERC20TokenOwnerDetails
  }
}
```

  

Token holders

```plain
fragment TokenDetails on EthTokenInfo {
  name
  symbol
  decimals
  totalSupply
  contract
}

fragment ERC20TokenOwnerDetails on ERC20TokenBalance  {
  tokenInfo {
    ...TokenDetails
  }
  owner
  balance
}

fragment ERC20TokenOwners on ERC20TokenOwners {
  owners {
    ...ERC20TokenOwnerDetails
  }
  nextKey
}


fragment ERC721TokenOwnerDetails on ERC721TokenOwner  {
  tokenInfo {
    ...TokenDetails
  }
  owner
  token
}

fragment ERC721TokenOwners on ERC721TokenOwners {
  owners {
    ...ERC721TokenOwnerDetails
  }
  nextKey
}

query getERC20TokenOwners($contract: String!, $_limit: Int, $_nextKey: String) {
  getERC20TokenOwners(contract: $contract, limit: $_limit, nextKey: $_nextKey) { 
    ...ERC20TokenOwners
  }
}

query getERC721TokenOwners($contract: String!, $_limit: Int, $_nextKey: String) {
  getERC721TokenOwners(contract: $contract, limit: $_limit, nextKey: $_nextKey) { 
    ...ERC721TokenOwners
  }
}
```

  

Token transfers

```plain
fragment TransferSummary on Transfer {
    transactionHash
    timestamp
    from
    to
    txFee
}
fragment TokenInfo on EthTokenInfo {
    name
    symbol
    decimals
    totalSupply
    contract
}

query getERC20TokenTransfers($hash: String!, $_limit: Int, $_nextKey: String) {
    getERC20TokenTransfers(contract: $hash, limit: $_limit, nextKey: $_nextKey) {
        transfers {
            transfer {
                ...TransferSummary
            }
            value
        }
        nextKey
    }
}


query getERC721TokenTransfers($hash: String!, $_limit: Int, $_nextKey: String) {
    getERC721TokenTransfers(contract: $hash, limit: $_limit, nextKey: $_nextKey) {
        transfers {
            transfer {
                ...TransferSummary
            }
            token
            contract
            tokenInfo {
                ...TokenInfo
            }
        }
        nextKey
    }
}
```

  

Transactions
------------

Block transactions

```plain
fragment TxSummary on ETHTransfers {
    transfers {
        transfer {
            transactionHash
            to
            block
            timestamp
            from
            txFee
            status
        }
        value
    }
}

query getBlockTransfers($_number: Int) {
    getBlockTransfers(number: $_number) {
        ...TxSummary
    }
}

query getAllTxs($_limit: Int, $_nextKey: String) {
    getAllEthTransfers(limit: $_limit, nextKey: $_nextKey) {
        ...TxSummary
        nextKey
    }
}

subscription newTransfersCompleteFeed {
    newTransfersCompleteFeed {
        block
        type
    }
}
```

  

Pending transactions

```plain
subscription pendingTx($owner: String) {
    pendingTransaction(owner: $owner) {
        transactionHash
        from
        to
        txFee
        value
        timestamp
    }
}

subscription txMined($hash: String!) {
    transactionEvent(hash: $hash)
}
```

  

Transaction details

```plain
fragment TxDetails on Tx {
    blockNumber
    from
    gas
    gasPrice
    gasUsed
    timestamp
    hash
    input
    status
    nonce
    to
    transactionIndex
    value
    replacedBy
    contractAddress
}

query getTransactionByHash($hash: String!) {
    getTransactionByHash(hash: $hash) {
        ...TxDetails
    }
}

subscription transactionEvent($hash: String!) {
    transactionEvent(hash: $hash)
}
```

  

Uncles
------

Uncle details

```plain
fragment UncleDetails on Uncle {
  block {
      summary {
        number
        miner
        txCount
        timestamp
        uncles
        rewards {
            txFees
            total
            uncles
        }
        txFail
    }
    hash
    parentHash
    nonce
    sha3Uncles
    logsBloom
    transactionsRoot
    stateRoot
    receiptsRoot
    difficulty
    totalDifficulty
    extraData
    size
    gasLimit
    gasUsed
    transactions
  }
  parentHash
  parentBlockNumber
  unclePosition
}

query getUncleByHash($hash: String!) {
  getUncleByHash(hash: $hash) {
    ...UncleDetails
  }
}
```

  

Search
------

Search details

```plain
query getHashType($hash: String!) {
  getHashType(hash: $hash)
}

query getTokensBeginsWith($keyword: String!) {
  getTokensBeginsWith(keyword: $keyword) {
    contract
    keyword
  }
}
```