GraphQL API

Flexible data querying for Ergo Platform. Fetch exactly what you need.

Introduction

GraphQL queries allow flexible data fetching, reducing over-fetching and under-fetching.gql.ergoplatform.com is a GraphQL server on top of Ergo Platform's explorer database schema.

Query Examples

Explore the schema visually using Apollo Studio or your favorite GraphQL client.
Here are some common queries you can try:

Fetching Box Details with Assets

query {
  boxes(boxId: "your_box_id") {
    boxId
    transactionId
    value
    address
    assets {
      tokenId
      amount
    }
  }
}

Fetching Transactions for Specific Addresses

query {
  transactions(addresses: ["address1", "address2"]) {
    transactionId
    inclusionHeight
    timestamp
  }
}

Fetching Balance for a List of Addresses

query {
  addresses(addresses: ["address1", "address2"]) {
    address
    balance {
      nanoErgs
      assets(tokenId: "your_token_id") {
        amount
        tokenId
      }
    }
  }
}

Fetching Details of Specific Tokens

query {
  tokens(tokenIds: ["token_id1", "token_id2"]) {
    tokenId
    boxId
    name
    description
  }
}

Fetching State of the Blockchain

query {
  state {
    blockId
    height
    boxGlobalIndex
    transactionGlobalIndex
    network
    difficulty
  }
}

Fetching the First 10 Transactions

query {
  transactions(take: 10) {
    transactionId
    size
    inclusionHeight
    timestamp
    inputs {
      boxId
      transactionId
    }
    outputs {
      boxId
      value
    }
  }
}

Advanced: Boxes Created Between Block Heights

query {
  boxes(minHeight: 1000, maxHeight: 2000) {
    boxId
    creationHeight
    value
    address
  }
}

Advanced: First 5 Transactions & Their Boxes

query {
  transactions(take: 5) {
    transactionId
    timestamp
    outputs {
      boxId
      value
      assets {
        tokenId
        amount
      }
    }
  }
}

Mutation: Submit Transaction

mutation {
  submitTransaction(signedTransaction: {
    id: "your_transaction_id",
    inputs: [
      {
        boxId: "your_box_id",
        spendingProof: {
          proofBytes: "your_proof_bytes",
          extension: {}
        }
      }
    ],
    dataInputs: [
      {
        boxId: "your_data_input_box_id"
      }
    ],
    outputs: [
      {
        value: "1000",
        ergoTree: "your_ergo_tree",
        creationHeight: 1000,
        assets: [
          {
            tokenId: "your_token_id",
            amount: "100"
          }
        ],
        additionalRegisters: {},
        index: 0
      }
    ],
    size: 100
  }) 
}

Query Categories

  • Fetching Box Details
  • Fetching Multiple Boxes with Specific Conditions
  • Fetching Specific Tokens
  • Fetching Tokens Associated with a Box
  • Fetching Inputs by Transaction or Box ID
  • Fetching Transactions with Specific Conditions
  • Fetching Data Inputs by Transaction or Box ID
  • Fetching Block Headers by Height or Header ID
  • Fetching Addresses with Balance and Transaction Count
  • Fetching the State of the Mempool
  • Fetching Blocks by Height or Header ID
  • Fetching the Current State of the Blockchain
  • Fetching Information about the Blockchain
  • Fetching the Balance for a List of Addresses
  • Fetching Transactions for Specific Addresses
  • Fetching Box Details with Assets
  • Fetching Unconfirmed Transactions from the Mempool
  • Fetching Unconfirmed Boxes from the Mempool
  • Fetching Unconfirmed Inputs from the Mempool
  • Fetching Unconfirmed Addresses from the Mempool