Sample cardano-graphql queries
Get the list of blocks, contained in an epoch
cardano-graphql query
query getBlocks($limit: Int!, $epoch: Int!) {
blocks(limit: $limit, where: { epoch: { number: { _eq: $epoch } } }) {
slotNo # cbeSlot
slotInEpoch # cbeEpoch
number # cbeBlkHeight
hash # cbeBlkHash
forgedAt # cbeTimeIssued
transactionsCount # cbeTxNum
transactions_aggregate {
aggregate {
sum {
totalOutput # cbeTotalSent
}
}
}
slotLeader {
hash # cbeBlockLead
}
size # cbeSize
fees # cbeFees
}
}
Variables
{ "limit": 2, "epoch": 86 }
Get block's summary information.
cardano-graphql query
query getBlock($hash: Hash32Hex!) {
blocks(limit: 1, where: { hash: { _eq: $hash } }) {
slotInEpoch # cbeEpoch
slotNo # cbeSlot
number # cbeBlkHeight
hash # cbeBlkHash
forgedAt # cbeTimeIssued
transactionsCount # cbeTxNum
transactions_aggregate {
aggregate {
sum {
totalOutput # cbeTotalSent
}
}
}
size # cbeSize
slotLeader {
hash # cbeBlockLead
}
fees # cbeFees
previousBlock {
hash # cbsPrevHash
}
nextBlock {
hash # cbsNextHash
}
merkelRoot # cbsMerkleRoot
}
}
Variables
{ "hash": "1fd784ef1814fd3e1bdf35c9cd9966ed3d92ba36b68e91504cf414493a657da6" }
Get summary information about a transaction.
cardano-graphql query
query getTxSummary($hash: Hash32Hex!) {
transactions(where: { hash: { _eq: $hash } }) {
hash # ctsId
includedAt # ctsTxTimeIssued
fee # ctsFees
block {
epochNo # ctsBlockEpoch
slotNo # ctsBlockSlot
slotInEpoch
number # ctsBlockHeight
hash # ctsBlockHash
}
inputs { # ctsInputs
address # ctaAddress
value # ctaAmount
sourceTxHash # ctaTxHash
sourceTxIndex # ctaTxIndex
}
inputs_aggregate {
aggregate {
sum {
value # ctsTotalInput
}
}
}
outputs { # ctsOutputs
address # ctaAddress
value # ctaAmount
index # ctaTxIndex
txHash # ctaTxHash
}
outputs_aggregate {
aggregate {
sum {
value # ctsTotalOutput
}
}
}
}
}
Variables
{ "hash": "382a5274ebf102910c6c923a8b11f108e79ecedb5d7433cd0dd15a8a443f0fa5" }
Get brief information about transactions including multi-assets
cardano-graphql query
query getBlockTxs($hash: Hash32Hex!) {
blocks (limit: 1, where: { hash: { _eq: $hash } }){
transactions {
hash # ctbId
includedAt # ctbTimeIssued
fee # ctbFees
inputs {
# ctbInputs
address # ctaAddress
value # ctaAmount
sourceTxHash # ctaTxHash
sourceTxIndex # ctaTxIndex
}
inputs_aggregate {
aggregate {
sum {
value # ctbInputSum
}
}
}
outputs { # ctbOutputs
address # ctaAddress
index # ctaTxIndex
value # ctaAmoun
transaction {
hash # ctaTxHash
mint {
asset {
assetId
assetName
policyId}
quantity}
}
tokens {
asset {
assetId
assetName
policyId}
quantity}
}
outputs_aggregate {
aggregate {
sum {
value # ctbOutputSum
}
}
}
}
}
}
Variables
{ "hash": "1fd784ef1814fd3e1bdf35c9cd9966ed3d92ba36b68e91504cf414493a657da6" }
Related documentation
Cardano GraphQL API documentation
cardano-rest migration guide (sample GQL queries)
Building & running cardano-graphql