Skip to content

Instantly share code, notes, and snippets.

@garethtdavies
Last active April 24, 2022 08:18
Show Gist options
  • Save garethtdavies/f55c8d9d2535cd392b00abff131592c4 to your computer and use it in GitHub Desktop.
Save garethtdavies/f55c8d9d2535cd392b00abff131592c4 to your computer and use it in GitHub Desktop.
MinaExplorer GraphQL API
{
transactions(
limit: 25
sortBy: DATETIME_DESC
query: {OR: [{to: "B62qqHM1bihHNvju89PFYugLw73PYRb7pGwp82CpEmWfSYVJiQAppaC"}, {from: "B62qqHM1bihHNvju89PFYugLw73PYRb7pGwp82CpEmWfSYVJiQAppaC"}], AND: {canonical: true, dateTime_gte: "2021-01-15T00:00:00Z"}}
) {
fee
canonical
from
to
nonce
amount
memo
hash
kind
dateTime
blockHeight
blockStateHash
}
}
{
blocks(
query: {creator: "B62qogU1qY33L8jwRmkwjN42xpSNrv8UkxaKrRFZxJSgbaNRMtpMTg7"}
sortBy: DATETIME_DESC,
limit: 10
) {
creator
canonical
stateHash
dateTime
protocolState {
consensusState {
blockHeight
}
}
transactions {
coinbase
}
}
}
{
blocks(
query: {
canonical: true
protocolState: { consensusState: { blockHeight: "2116" } }
}
) {
stateHash
creator
canonical
dateTime
}
}
{
snarks(
limit: 10
query: {prover: "B62qogU1qY33L8jwRmkwjN42xpSNrv8UkxaKrRFZxJSgbaNRMtpMTg7"}
sortBy: DATETIME_DESC
) {
fee
dateTime
block {
stateHash
protocolState {
consensusState{
blockHeight
}
}
}
canonical
}
}
{
transactions(
limit: 10
sortBy: DATETIME_DESC
query: {from: "B62qogU1qY33L8jwRmkwjN42xpSNrv8UkxaKrRFZxJSgbaNRMtpMTg7", canonical: true}
) {
fee
from
to
nonce
amount
block {
stateHash
protocolState {
consensusState {
blockHeight
}
}
}
memo
hash
kind
dateTime
}
}
@garethtdavies
Copy link
Author

garethtdavies commented Jan 16, 2021

For example to get the last 10 blocks produced by a public key:

curl 'https://graphql.minaexplorer.com' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' --data-binary '{"query":"{\n  blocks(\n    query: {creator: \"B62qogU1qY33L8jwRmkwjN42xpSNrv8UkxaKrRFZxJSgbaNRMtpMTg7\"}\n    sortBy: DATETIME_DESC\n  ) {\n    creator\n    canonical\n    stateHash\n    dateTime\n    protocolState {\n      consensusState {\n        blockHeight\n      }\n    }\n    transactions {\n      coinbase\n    }\n  }\n}","variables":{}}' --compressed

@garethtdavies
Copy link
Author

Also see https://altair.sirmuel.design/ for a useful GraphQL GUI that will generate the above requests for you.

@garethtdavies
Copy link
Author

Find a delegation transaction:

query {
  transactions(
    query: {
      from: "B62qk8nQLZdDDm5VH6nZMpSf8eJwY3rDZa9U7Mz5St8bpu7gRp2t1CA"
      canonical: true
      isDelegation: true
    }
  ) {
    from
    to
    amount
    dateTime
    blockHeight
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment