2

I am looking for a GraphQL query that will return transaction details as seen on the Cardano Blockchain Explorer when searched with txId.

For example,

https://explorer.cardano.org/en/transaction?id=f58152cafbd25e618433eae52f72bb419e00efe91b5cf7c74a93f8c29cbb2e7b

Can anyone provide a sample query which can also be tested on the Dandelion GraphQL playground?

2

1 Answer 1

1

To check exact query as explorer for GraphQL - in your browser, when viewing page from explorer - you can check Developer Tools > Network (tab). In the list, look for graphql POST requests where variable is your transaction ID - you would see the graphql query in Request Payload.

Thus, for the mentioned link in example , you'd see the request is:

{"query":"query searchById($id: Hash32Hex!) {\n  blocks(where: {hash: {_eq: $id}}) {\n    ...BlockDetails\n  }\n  transactions(where: {hash: {_eq: $id}}) {\n    ...TransactionDetails\n  }\n}\n\nfragment BlockDetails on Block {\n  ...BlockOverview\n  nextBlock {\n    hash\n    number\n  }\n  previousBlock {\n    hash\n    number\n  }\n  transactions(limit: 10, order_by: {fee: desc}) {\n    ...TransactionDetails\n  }\n}\n\nfragment BlockOverview on Block {\n  forgedAt\n  slotLeader {\n    description\n  }\n  epochNo\n  hash\n  number\n  size\n  slotNo\n  transactions_aggregate {\n    aggregate {\n      count\n      sum {\n        totalOutput\n      }\n    }\n  }\n}\n\nfragment TransactionDetails on Transaction {\n  block {\n    epochNo\n    hash\n    number\n    slotNo\n  }\n  deposit\n  fee\n  hash\n  includedAt\n  mint {\n    asset {\n      assetName\n      decimals\n      description\n      fingerprint\n      name\n      policyId\n      ticker\n    }\n    quantity\n  }\n  inputs {\n    address\n    sourceTxHash\n    sourceTxIndex\n    value\n    tokens {\n      asset {\n        assetName\n        decimals\n        description\n        fingerprint\n        name\n        policyId\n        ticker\n      }\n      quantity\n    }\n  }\n  metadata {\n    key\n    value\n  }\n  outputs {\n    address\n    index\n    value\n    tokens {\n      asset {\n        assetName\n        decimals\n        description\n        fingerprint\n        name\n        policyId\n        ticker\n      }\n      quantity\n    }\n  }\n  totalOutput\n  withdrawals {\n    address\n    amount\n  }\n}\n","variables":{"id":"f58152cafbd25e618433eae52f72bb419e00efe91b5cf7c74a93f8c29cbb2e7b"}}

Note that this is ofcourse a request payload sent to graphql endpoint, you can substitute \n and use/replace variable(s) as desired

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.