Gauss Docs
  • 🌐Getting Started
    • Welcome to Gauss
    • Whitepaper
      • Blockchain Providers Need to Do Better
        • Solving a Lack of Token Adoption
          • An Evolving Space With Untapped Potential
        • Security & Reliability
          • Curation & Vetting
            • Important Note For Brands
        • Token Creation
      • WHY BUILD WITH GAUSS?
      • Use Cases
        • Use Cases (Chart)
      • Roadmap
      • Technical Background and Blockchain Development
        • Why Another Blockchain?
        • Gauss 1.0: Built With Efficiency and a Strong Infrastructure to Launch Rapidly
        • Gauss 2.0: Added Functionality For a Better User Experiance
          • Noble Swap 2.0
          • NFTs in Gauss 2.0
          • Token Development Kit (TDK)
          • Gaming DAO
          • Omnipool
      • Token Economics
        • Gang Token Economics: Designed to Ensure Trust and Transparency
        • Token Locking Schedule
        • Reflections: Rewarding the Gauss Community
        • Charitable Allocations: Grants, Scholarships, & Financial Assistance
      • The Gauss Team
      • Important Definitions
      • DISCLAIMER
        • PURCHASER WARNING
        • PROMINENT STATEMENTS
        • FUTURE STATEMENTS
        • VALUE RISKS
        • NOT A SECURITY
    • How To Connect
      • Create Metamask Wallet
    • Links
  • ⚡Launching with Gauss
    • Benefits of Building with Gauss
      • Fostering an Environment for Success
      • Gauss Growth Grant Program
      • Gauss Liquidity Program
      • Ecosystem Integrity Fund
      • Client Referral Program
    • A Guide to Curation
      • Core Principles and Curation Guidelines
      • Curation Stages and Processing Fees
    • Building on Gauss
  • 🖥️Gauss Ecosystem
    • Gauss Chain
      • Polygon-Edge Overview
      • Architecture
      • Consensus
      • Client Modules
        • Blockchain
        • Minimal
        • Networking
        • State
        • TxPool
        • JSON RPC
        • Consensus
        • Storage
        • Types
        • Syncer
        • Sealer
        • Other Modules
      • Polygon-Edge Performance Reports
      • For Developers
        • Operate a Node
          • Local Install
          • Genesis Contract
          • Server Config
          • CLI Commands
          • Key Management
        • Run a Validator
          • Validator FAQ
        • Smart Contract Deployment Permissioning
        • Deploying Contracts
          • Remix
          • Truffle
          • Hardhat
          • Replit
    • Gauss Explorer
      • Features
      • Navigating the Explorer
        • Menus
        • Blocks
        • Transactions
      • Verifying a Smart Contract
        • Hardhat Plugin
        • Sourcify Plugin
        • OpenZeppelin Plugin
      • Interacting With Smart Contracts
      • Exporting Transactions
      • FAQ
      • For Developers
        • Gauss Explorer Dependencies
        • Deployment Guide
          • Smart Contract Verification
          • Cleaning an instance from the previous deployment
          • ENV Variables
          • Testing
        • APIs
          • Requests & Limits
          • GraphQL
          • ETH RPC
    • Noble Swap
      • Liquidity Boost Program
    • Tokens
    • Gauss NFTs
      • Ferro Cards
      • F.E.R.R.E.T. NFTs
    • Contests & Giveaways
    • Gauss Faucet
      • For Developers
    • Address List
  • 💡Additional Resources
    • Partnerships & Affiliates
    • Discord Channel
    • Contact Us
    • Learning Materials
      • Web3 Glossary
    • Media Kit
Powered by GitBook
On this page
  • What is GraphQL
  • Query types
  • Access GraphQL API
  • Queries
  1. Gauss Ecosystem
  2. Gauss Explorer
  3. For Developers
  4. APIs

GraphQL

What is GraphQL

GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data. It provides an efficient, powerful and flexible approach to developing web APIs. It allows clients to define the structure of the data required, and exactly the same structure of the data is returned from the server, therefore preventing excessively large amounts of data from being returned.Key concepts of the GraphQL query language are:

  • Hierarchical

  • Strongly typed

  • Client-specified queries

Advantages of GraphQL:

  • Declarative integration on client (what data/operations do I need)

  • A standard way to expose data and operations

  • Support for real-time data (with subscriptions)

Query types

There are three main query types in GraphQL schema:

1) Query: fetch data

query {
  allPosts {
    description
    text
  }
}

2) Mutation: change data.

   mutation {
     updatePost(id: 1, text: "text") {
       text
     }
   }
  1. Subscription: subscribe to real-time data.

subscription {
  newPost(category: [1]) {
    description
    text
  }
}

Access GraphQL API

To access Blockscout GraphQL interface you can use GraphiQL - in-browser IDE for exploring GraphQL. It's built in to Blockscout.From the APIs dropdown menu choose GraphQL. Depending on the implementation you may also find the link in the page footer.

You can also use your favorite http client:

curl 'https://blockscout.com/eth/kovan/graphiql'
  -H 'Authorization: Bearer YOUR_AUTH_TOKEN'
  -d '{"query":""{transaction(hash:\"0x69e3923eef50eada197c3336d546936d0c994211492c9f947a24c02827568f9f\"){blockNumbertoAddressHashfromAddressHashcreatedContractAddressHashvaluestatusnoncehasherrorgasgasPricegasUsedcumulativeGasUsedidindexinputrsv}}""}'

Queries

Blockscout's GraphQL API provides queries and a subscription. You can view them in the GraphQL interface in the Docs menu. Example Queries:

Query

Description

Example

address(hash: AddressHash!): Address

Gets an address by hash

{address(hash: "0x1fddEc96688e0538A316C64dcFd211c491ECf0d8") {hash, contractCode} }

addresses (hashes: [AddressHash!]): [Address]

Gets addresses by hashes

{addresses(hashes: ["0x1fddEc96688e0538A316C64dcFd211c491ECf0d8", "0x3948c17c0f45017064858b8352580267a85a762c"]) {hash, contractCode} }

block(number: Int!): Block

Gets a block by number

{block(number: 1) {parentHash, size, nonce}}

transaction (hash: FullHash!): Transaction

Gets a transaction by hash.

{transaction(hash: "0xc391da8f433b3bea0b3eb45da40fdd194c7a0e07d1b5ad656bf98940f80a6cf6") {input, gasUsed}}

Example Query to retrieve transactions for a specific address

{
  address(hash: "0x...") {
    transactions(first:5) {
      edges {
        node {
          blockNumber
          createdContractAddressHash
          fromAddressHash
          gas
          hash
        }
      }
    }
  }
}

Note that transactions can accept the following arguments:

  • first

  • after

  • before

PreviousRequests & LimitsNextETH RPC

Last updated 2 years ago

🖥️