Skip to main content

Sui GraphQL RPC


Facts

Fact Sheet

  • Sui GraphQL RPC is currently in beta
  • Sui GraphQL RPC beta operates on both testnet and mainnet at this time
  • Sui GraphQL RPC will eventually replace the JSON RPC
  • Sui support and constraints defined Hereopen in new window
  • PySui support for Sui GraphQL RPC:
    • Release 0.50.0 includes an 'experimental' implementation, subject to change
    • Provides Synchronous and asynchronous GraphQL clients
    • Read queries, DryRun and Execute transactions are supported
    • Introduces QueryNodes that are the equivalent to pysui Builders
    • Parity of QueryNodes to Builders is complete
    • Exposes ability for developers to write their own GraphQL queries
    • SuiConfiguration must point to either Sui's testnet or mainnet RPC URLs
    • pysui GraphQL documentation is in the Docsopen in new window

Generating GraphQL schema

sui
NA

Query example 1

For pysui there are 3 comon ways to create a query. This demonstrates using QueryNodes (predefined queries as part of pysui SDK)

sui
NA at this time

Dryrun example 1

This demonstrates performing a dryRun of a transaction block

sui
NA at this time

Dryrun example 2

This demonstrates performing a dryRun of a transactions kind

sui
NA at this time

Execute example

This demonstrates performing a execution of a transactions

sui
NA at this time

Query example 2

For pysui there are 3 comon ways to create a query. This demonstrates using a query string

sui
# basic query
curl -X POST https://graphql-beta.mainnet.sui.io \
     --header "Content-Type: application/json" \
     --data '{
          "query": "query { epoch { referenceGasPrice } }"
     }'
# query with variables
curl -X POST https://graphql-beta.mainnet.sui.io \
     --header "Content-Type: application/json" \
     --data '{
          "query": "query ($epochID: Int!) { epoch(id: $epochID) { referenceGasPrice } }", "variables": { "epochID": 123 }
     }'

Query example 3

For pysui there are 3 comon ways to create a query. This demonstrates using gqlopen in new window the underlying GraphQL library to generate a DocumentNode

sui
NA