For Acki Nacki Developers
Acki Nacki docsFor DevelopersFor Validators
  • About Acki Nacki SDK
  • How to deploy a Multisig Wallet
  • Dapp ID Full Guide: creation, fees, centralized replenishment
  • Quick Starts
    • Quick Start TVM SDK JavaScript
    • GraphQL Quick Start
  • Reference
    • Core Library Reference
      • Modules
      • Module abi
      • Module boc
      • Module client
      • Module crypto
      • Module debot
      • Module net
      • Module processing
      • Module proofs
      • Module tvm
      • Module utils
    • Core Library Error API
    • Error Codes
    • TVM-CLI Reference
  • VM Instructions
    • Acki Nacki VM Instructions
    • Formal Verification
      • Acki Nacki VM Instructions Business-Level Specification
  • GraphQL
    • GraphQL API
    • Schema
    • Blockchain API
    • Query Collections: Query Language
    • Field Descriptions
    • Info API
    • Web Playground
    • Examples
  • ABI
    • ABI Specification
  • Examples
    • Client Libraries JS Examples
    • GraphQL API Examples
      • Connect to GraphQL API
      • Send message
      • Accounts
      • Blocks
      • Messages
      • Block and Transaction Pagination: Best Practice
      • Transactions
  • For Binding Developers
    • How to work with Application Objects in binding generators
    • JSON Interface to TVM Client
  • Links
    • TVM SDK repository
Powered by GitBook
On this page
  1. Examples
  2. GraphQL API Examples

Connect to GraphQL API

HTTPS

curl --location --request POST https://shellnet.ackinacki.org/graphql \
--header 'Content-Type: application/json' \
--data-raw '{"query":"query{\n  blockchain{\n    blocks(last:1){\n      edges{\n        node{\n          hash\n          seq_no\n        }\n      }\n    }\n  }\n}","variables":{}}'
const {TvmClient} = require("@tvmsdk/core");
const {libNode} = require("@tvmsdk/lib-node");

TvmClient.useBinaryLibrary(libNode)

const client = new TvmClient({
    network: {
        endpoints: [
            "endpoint"
        ],
    },
});

(async () => {
    try {
        queryString = `
            query{
                blockchain{
                blocks(last:1){
                    edges{
                    node{
                        hash
                        seq_no
                    }
                    }
                }
                }
            }
        `
        let {seq_no, hash} = (await client.net.query({ 
            "query": queryString }))
        .result.data.blockchain.blocks.edges[0].node;
        console.log("The last masterchain block seqNo is " + seq_no+ '\n' + "the hash is" + hash);
        client.close();
}
    catch (error) {
            console.error(error);
    }
}
)()
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

var graphql = JSON.stringify({
  query: "query{\n  blockchain{\n    blocks(last:1){\n      edges{\n        node{\n          hash\n          seq_no\n        }\n      }\n    }\n  }\n}",
  variables: {}
})
var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: graphql,
  redirect: 'follow'
};

fetch("endpoint", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
URL: endpoint
Body: GraphQL
Query:

query{
  blockchain{
    blocks(last:1){
      edges{
        node{
          hash
          seq_no
        }
      }
    }
  }
}

In the next section find out how to work with GraphQL Web playground and easily explore blockchain data with it.

PreviousGraphQL API ExamplesNextSend message

Last updated 7 months ago