Protokit GraphQL API

Explore all queries, mutations, subscriptions, and types provided by Protokit.

API Endpoints
http://localhost:8080/graphql

Queries

batches

Description

Returns previously computed batches of blocks used for settlement

Response

Returns a ComputedBlockModel

Arguments
Name Description
height - Float Filters the batches for a specific height

Example

Query
query batches($height: Float) {
  batches(height: $height) {
    blocks {
      ...BlockModelFragment
    }
    proof
  }
}
Variables
{"height": 123.45}
Response
{
  "data": {
    "batches": {
      "blocks": [BlockModel],
      "proof": "abc123"
    }
  }
}

block

Description

Queries for blocks that have been sequenced and included into the chain

Response

Returns a BlockModel

Arguments
Name Description
hash - String Filters the blocks for a specific hash
height - Float Filters the blocks for a specific height

Example

Query
query block(
  $hash: String,
  $height: Float
) {
  block(
    hash: $hash,
    height: $height
  ) {
    hash
    previousBlockHash
    height
    txs {
      ...BatchTransactionModelFragment
    }
    transactionsHash
  }
}
Variables
{"hash": "xyz789", "height": 123.45}
Response
{
  "data": {
    "block": {
      "hash": "abc123",
      "previousBlockHash": "abc123",
      "height": 987.65,
      "txs": [BatchTransactionModel],
      "transactionsHash": "abc123"
    }
  }
}

network

Response

Returns a network

Example

Query
query network {
  network {
    unproven {
      ...NetworkFragment
    }
    staged {
      ...NetworkFragment
    }
    proven {
      ...NetworkFragment
    }
  }
}
Response
{
  "data": {
    "network": {
      "unproven": Network,
      "staged": Network,
      "proven": Network
    }
  }
}

node

Description

Retrieves general information about the appchain

Response

Returns a NodeInformationObject!

Example

Query
query node {
  node {
    blockHeight
    batchHeight
  }
}
Response
{"data": {"node": {"blockHeight": 987.65, "batchHeight": 123.45}}}

protocol

Response

Returns a Protocol

Example

Query
query protocol {
  protocol {
    AccountState {
      ...AccountStateFragment
    }
  }
}
Response
{"data": {"protocol": {"AccountState": AccountState}}}

runtime

Response

Returns a Runtime

Example

Query
query runtime {
  runtime {
    Balances {
      ...BalancesFragment
    }
  }
}
Response
{"data": {"runtime": {"Balances": Balances}}}

state

Description

Allows the raw querying of values inside a specific state slot. Returns a string[] that represents the field-encoding of the given value

Response

Returns [String!]

Arguments
Name Description
path - String! The path to the state slot to be queried

Example

Query
query state($path: String!) {
  state(path: $path)
}
Variables
{"path": "abc123"}
Response
{"data": {"state": ["abc123"]}}

transactionState

Description

Returns the state of a given transaction

Response

Returns an InclusionStatus!

Arguments
Name Description
hash - String! The hash of the transaction to be queried for

Example

Query
query transactionState($hash: String!) {
  transactionState(hash: $hash)
}
Variables
{"hash": "abc123"}
Response
{"data": {"transactionState": "UNKNOWN"}}

transactions

Description

Returns the hashes of all transactions that are currently inside the mempool

Response

Returns [String!]!

Example

Query
query transactions {
  transactions
}
Response
{"data": {"transactions": ["abc123"]}}

witness

Description

Allows retrieval of merkle witnesses corresponding to a specific path in the appchain's state tree. These proves are generally retrieved from the current 'proven' state

Response

Returns a MerkleWitnessDTO!

Arguments
Name Description
path - String!

Example

Query
query witness($path: String!) {
  witness(path: $path) {
    siblings
    isLefts
  }
}
Variables
{"path": "xyz789"}
Response
{
  "data": {
    "witness": {
      "siblings": ["abc123"],
      "isLefts": [true]
    }
  }
}

Mutations

submitTx

Description

Adds a transaction to the mempool and validates it

Response

Returns a String!

Arguments
Name Description
tx - TransactionObjectInput!

Example

Query
mutation submitTx($tx: TransactionObjectInput!) {
  submitTx(tx: $tx)
}
Variables
{"tx": TransactionObjectInput}
Response
{"data": {"submitTx": "abc123"}}

Types

AccountState

Fields
Field Name Description
accountState - ProtocolAccountStateaccountStateValue
Example
{"accountState": ProtocolAccountStateaccountStateValue}

Balances

Fields
Field Name Description
circulatingSupply - RuntimeBalancescirculatingSupplyValue
balances - RuntimeBalancesbalancesValue
Arguments
Example
{
  "circulatingSupply": RuntimeBalancescirculatingSupplyValue,
  "balances": RuntimeBalancesbalancesValue
}

BatchTransactionModel

Fields
Field Name Description
tx - TransactionObject!
status - Boolean!
statusMessage - String
Example
{
  "tx": TransactionObject,
  "status": false,
  "statusMessage": "abc123"
}

BlockModel

Fields
Field Name Description
hash - String!
previousBlockHash - String
height - Float!
txs - [BatchTransactionModel!]!
transactionsHash - String!
Example
{
  "hash": "abc123",
  "previousBlockHash": "abc123",
  "height": 987.65,
  "txs": [BatchTransactionModel],
  "transactionsHash": "abc123"
}

Boolean

Description

The Boolean scalar type represents true or false.

Example
true

ComputedBlockModel

Fields
Field Name Description
blocks - [BlockModel!]!
proof - String!
Example
{
  "blocks": [BlockModel],
  "proof": "xyz789"
}

Float

Description

The Float scalar type represents signed double-precision fractional values as specified by IEEE 754.

Example
987.65

InclusionStatus

Values
Enum Value Description

UNKNOWN

PENDING

INCLUDED

SETTLED

Example
"UNKNOWN"

MerkleWitnessDTO

Fields
Field Name Description
siblings - [String!]!
isLefts - [Boolean!]!
Example
{"siblings": ["xyz789"], "isLefts": [false]}

Network

Fields
Field Name Description
block - Networkblock
previous - Networkprevious
Example
{
  "block": Networkblock,
  "previous": Networkprevious
}

Networkblock

Fields
Field Name Description
height - String
Example
{"height": "abc123"}

Networkprevious

Fields
Field Name Description
rootHash - String
Example
{"rootHash": "abc123"}

NodeInformationObject

Fields
Field Name Description
blockHeight - Float!
batchHeight - Float!
Example
{"blockHeight": 123.45, "batchHeight": 987.65}

Protocol

Fields
Field Name Description
AccountState - AccountState
Example
{"AccountState": AccountState}

ProtocolAccountStateaccountStateKey

Fields
Input Field Description
x - String
isOdd - Boolean
Example
{"x": "xyz789", "isOdd": false}

ProtocolAccountStateaccountStateValue

Fields
Field Name Description
nonce - String
Example
{"nonce": "abc123"}

Runtime

Fields
Field Name Description
Balances - Balances
Example
{"Balances": Balances}

RuntimeBalancesbalancesKey

Fields
Input Field Description
tokenId - String
address - RuntimeBalancesbalancesKeyaddress
Example
{
  "tokenId": "xyz789",
  "address": RuntimeBalancesbalancesKeyaddress
}

RuntimeBalancesbalancesKeyaddress

Fields
Input Field Description
x - String
isOdd - Boolean
Example
{"x": "abc123", "isOdd": true}

RuntimeBalancesbalancesValue

Fields
Field Name Description
value - String
Example
{"value": "abc123"}

RuntimeBalancescirculatingSupplyValue

Fields
Field Name Description
value - String
Example
{"value": "xyz789"}

Signature

Fields
Field Name Description
r - String!
s - String!
Example
{
  "r": "xyz789",
  "s": "abc123"
}

SignatureInput

Fields
Input Field Description
r - String!
s - String!
Example
{
  "r": "abc123",
  "s": "abc123"
}

String

Description

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Example
"xyz789"

TransactionObject

Fields
Field Name Description
hash - String!
methodId - String!
sender - String!
nonce - String!
signature - Signature!
argsFields - [String!]!
auxiliaryData - [String!]!
isMessage - Boolean!
Example
{
  "hash": "xyz789",
  "methodId": "abc123",
  "sender": "abc123",
  "nonce": "xyz789",
  "signature": Signature,
  "argsFields": ["xyz789"],
  "auxiliaryData": ["abc123"],
  "isMessage": true
}

TransactionObjectInput

Fields
Input Field Description
hash - String!
methodId - String!
sender - String!
nonce - String!
signature - SignatureInput!
argsFields - [String!]!
auxiliaryData - [String!]!
isMessage - Boolean!
Example
{
  "hash": "xyz789",
  "methodId": "xyz789",
  "sender": "abc123",
  "nonce": "xyz789",
  "signature": SignatureInput,
  "argsFields": ["xyz789"],
  "auxiliaryData": ["abc123"],
  "isMessage": true
}

network

Fields
Field Name Description
unproven - Network
staged - Network
proven - Network
Example
{
  "unproven": Network,
  "staged": Network,
  "proven": Network
}