Skip to content

Latest commit

 

History

History
406 lines (301 loc) · 9.9 KB

ref-01-api-commands.adoc

File metadata and controls

406 lines (301 loc) · 9.9 KB

Standard RPC Commands and Subscriptions

RPC Commands

Submit Extrinsic (author_submitExtrinsic)

Submit a fully formatted extrinsic for block inclusion

Shortcut

StandardCommands.getInstance().authorSubmitExtrinsic(ByteData)

Command

author_submitExtrinsic

Parameters

encoded extrinsic

Java Object

Hash256

List Pending Extrinsics (author_pendingExtrinsics)

Returns all pending extrinsics

Shortcut

StandardCommands.getInstance().authorPendingExtrinsics()

Command

author_pendingExtrinsics

Parameters

none

Java Object

List<ByteData>

Remove Extrinsic (author_removeExtrinsic)

Remove given extrinsic(s) from the pool and temporarily ban it to prevent reimporting

Shortcut

StandardCommands.getInstance().authorRemoveExtrinsic()

Command

author_removeExtrinsic

Parameters

extrinsic(s) hash(es) or original extrinsic(s)

Java Object

List<Hash256>

Has Key (author_hasKey)

Returns true if the keystore has private keys for the given public key and key type.

Shortcut

StandardCommands.getInstance().authorHasKey()

Command

author_hasKey

Parameters

address/public key, key type

Java Object

Boolean

Has Session Keys (author_hasSessionKeys)

Returns true if the keystore has private keys for the given session public keys.

Shortcut

StandardCommands.getInstance().authorHasSessionKeys()

Command

author_hasSessionKeys

Parameters

bytes

Java Object

Boolean

Insert Key (author_insertKey)

Insert a key into the keystore.

Shortcut

StandardCommands.getInstance().authorInsertKey()

Command

author_insertKey

Parameters

key type, suri, address/public key

Java Object

ByteData

Rotate Keys (author_rotateKeys)

Generate new session keys and returns the corresponding public keys.

Shortcut

StandardCommands.getInstance().authorRotateKeys()

Command

author_rotateKeys

Parameters

none

Java Object

ByteData

Get Block (chain_getBlock)

Get block by its hash

Shortcut

StandardCommands.getInstance().getBlock(Hash256)

Command

chain_getBlock

Parameters

hash of the requested block

Java Object

BlockResponseJson

Get Block Hash (chain_getBlockHash)

Get the block hash for a specific block

Shortcut

StandardCommands.getInstance().getBlockHash(at)

Command

chain_getBlockHash

Parameters

at - (optional) block height

Java Object

Hash256

BlockResponseJson Properties
  • BlockJson getBlock() block details

  • Object getJustification()

Get Finalised Head (chain_getFinalizedHead)

Get the hash of the finalized head

Shortcut

StandardCommands.getInstance().getFinalizedHead()

Command

chain_getFinalizedHead

Parameters

none

Java Object

Hash256

Get Head (chain_getHead)

Get the hash of the head

Shortcut

StandardCommands.getInstance().getHead()

Command

chain_getHead

Parameters

none

Java Object

Hash256

Get Runtime Version (chain_getRuntimeVersion)

Get the Runtime Version of the current blockchain

Shortcut

StandardCommands.getInstance().getRuntimeVersion()

Command

chain_getRuntimeVersion

Parameters

none

Java Object

RuntimeVersionJson

RuntimeVersionJson Properties
  • List<List<?>> getApis()

  • Integer getAuthoringVersion()

  • String getImplName()

  • Integer getImplVersion()

  • String getSpecName()

  • Integer getSpecVersion()

  • Integer getTransactionVersion()

Contracts Call (contracts_call)

Executes a call to a contract

Shortcut

StandardCommands.getInstance().contractsCall(call, at)

Command

contracts_call

Parameters

call - requests data ContractCallRequestJson, at - (optional) block reference (Hash256)

Java Object

ContractExecResultJson

Contracts Get Storage (contracts_getStorage)

Get value under a specified storage key in a contract.

Shortcut

StandardCommands.getInstance().contractsGetStorage(address, key, at)

Command

contracts_getStorage

Parameters
  • address - contract address (Address),

  • key - key (Has256),

  • at - (optional) block reference (Hash256)

Java Object

ByteData

Contracts Rent Projection (contracts_rentProjection)

Get projected time a given contract will be able to sustain paying its rent

Shortcut

StandardCommands.getInstance().contractsRentProjection(address, at)

Command

contracts_getStorage

Parameters
  • address - contract address (Address),

  • at - (optional) block reference (Hash256)

Java Object

Long

State Runtime Metadata (state_getMetadata)

Get name of the current blockchain

Shortcut

StandardCommands.getInstance().stateMetadata()

Command

state_getMetadata

Parameters

none

Java Object

ByteData

The metadata is encoded with SCALE codec, if you need to decode the object use:

Future<Metadata> metadataFuture = client.execute(StandardCommands.getInstance().stateMetadata())
        .thenApply(ByteData::getBytes)
        .thenApply(ScaleExtract.fromBytes(new MetadataReader()));

State Get Storage (state_getStorage)

Get state from a Storage.

Shortcut

StandardCommands.getInstance().stateGetStorage(key)

Command

state_getStorage

Parameters

key - bytes (byte[] or ByteDate)

Java Object

ByteData

State Get Read Proof (state_getReadProof)

Get proof of storage entries at a specific block state

Shortcut

StandardCommands.getInstance().stateGetReadProof(keys, at?)

Command

state_getReadProof

Parameters
  • keys - list of keys (List<ByteDate>)

  • at - (optional) block reference (Hash256)

Java Object

ReadProofJson

System Chain (system_chain)

Get name of the current blockchain

Shortcut

StandardCommands.getInstance().systemChain()

Command

system_chain

Parameters

none

Java Object

String

System Health (system_health)

Get health status of the node

Shortcut

StandardCommands.getInstance().systemHealth()

Command

system_health

Parameters

none

Java Object

SystemHealthJson

SystemHealthJson Properties
  • Boolean getSyncing - true if node does initial syncing

  • Integer getPeers() - amount of current peers

  • Boolean getShouldHavePeers() - true if node should have peers

System Name (system_name)

Get name of the current node

Shortcut

StandardCommands.getInstance().systemName()

Command

system_name

Parameters

none

Java Object

String

System Node Roles (system_nodeRoles)

Get roles of the current node

Shortcut

StandardCommands.getInstance().systemNodeRoles()

Command

system_nodeRoles

Parameters

none

Java Object

List<String>

System Peers (system_peers)

Get peer list connected to the current node

Shortcut

StandardCommands.getInstance().systemPeers()

Command

system_peers

Parameters

none

Java Object

List<PeerJson>

PeerJson Properties
  • Hash256 getBestHash()

  • Long getBestNumber()

  • String getPeerId()

  • Integer getProtocolVersion()

  • String getRoles()

System Version (system_version)

Get version of the current node

Shortcut

StandardCommands.getInstance().systemVersion()

Command

system_version

Parameters

none

Java Object

String

Methods List (rpc_methods)

Get list of all available RPC methods

Shortcut

StandardCommands.getInstance().methods()

Command

rpc_methods

Parameters

none

Java Object

MethodsJson

MethodsJson Properties
  • Integer getVersion() - version of RPC

  • List<String> getMethods() - list of methods

Payment Query (payment_queryInfo)

Retrieves the fee information for an encoded extrinsic

Shortcut

StandardCommands.getInstance().paymentQueryInfo()

Command

payment_queryInfo

Parameters

extrinsic, (optional) block hash

Java Object

RuntimeDispatchInfoJson

Account Next Index (account_nextIndex)

Next index for the address

Shortcut

StandardCommands.getInstance().accountNextIndex()

Command

account_nextIndex

Parameters

address

Java Object

Integer

Subscriptions

Finalized Heads (chain_subscribeFinalizedHeads)

Subscribe to the finalized head changes, i.e. to the finalized block on the head of the current blockchain.

Shortcut

StandardSubscriptions.getInstance().finalizedHeads()

Command

chain_subscribeFinalizedHeads

Parameters

none

Java Object

BlockJson.Header

New Heads (chain_subscribeNewHead)

Subscribe to the head changes, i.e. to block on the head of the current blockchain.

Shortcut

StandardSubscriptions.getInstance().newHeads()

Command

chain_subscribeNewHead

Parameters

none

Java Object

BlockJson.Header

Runtime Version (state_subscribeRuntimeVersion)

Subscribe to the changes to the Runtime Version.

Shortcut

StandardSubscriptions.getInstance().runtimeVersion()

Command

state_subscribeRuntimeVersion

Parameters

none

Java Object

RuntimeVersion

Storage (state_subscribeStorage)

Subscribe to the changes to the Storage.

Shortcut

StandardSubscriptions.getInstance().storage(keys?)

Command

state_subscribeRuntimeVersion

Parameters

keys - (optional) Storage Keys (Hash256)

Java Object

StorageChangeSetJson