How to Interface with the ixo blockchain SDK
The ixo blockhain SDK provides three interfaces for interacting with a node:
command-line interface
gRPC interface
REST interface
Each interface can be used to query the state. The command-line interface can be used to generate, sign, and broadcast transactions, whereas the gRPC and REST interfaces can only be used to broadcast transactions (a transaction needs to be generated and signed either programmatically or using the command-line interface before it can be broadcasted using the gRPC or REST interfaces).
The most straightforward way to interact with a node is using the command-line interface; also known as CLI.
The ixo binary serves as the node client and the application client, meaning the ixo
binary can be used to both run a node and interact with it. In Quick Start, we started a local node using the ixo
binary and then interact with that node by submitting queries and transactions.
To learn more about the available commands, install ixo and run the following:
For transaction commands:
For query commands:
For more information about the CLI, check out the Cosmos SDK Documentation.
gRPC is a modern RPC framework that leverages protocol buffers for encoding requests and responses between a client and service. The ixo blockchain SDK uses gRPC primarily for querying blockchain state (token balances, data signature records, etc). As a client developer, this means you can query the ixo blockchain state directly by using a gRPC library in your programming language of choice, in combination with the ixo blockchain protobuf definitions .
In addition to using a gRPC library, you can also use grpcurl - a command-line tool that lets you interact with gRPC servers. If you have a local node running, you can list the protobuf services available using the following command:
To execute a call, you can use the following format:
In some programming languages, you may be able to leverage a pre-existing client library to take care of most of the heavy lifting, including compiling protobuf messages. For javascript/typescript developers, the ixo Client-SDK (based on CosmJS) is a good place to start.
For more information about the gRPC interface, check out the Cosmos SDK Documentation.
All gRPC services and methods for the ixo blockchain SDK are available for more convenient REST based queries through gRPC Gateway.
For example, you can query the balance of an address using the following curl
command:
To interact with the REST interface, make sure you have API server and (optionally) Swagger UI enabled in your ~/.ixo/config/app.toml
file. With Swagger UI enabled, you can go to http://localhost:1317/swagger/
to read through the OpenAPI documentation.
For more information about the REST interface, check out the Cosmos SDK Documentation.
The Impact blockchain for the Cosmos ecosystem
The following instructions allow you to run a single node network on your local machine and interact with it using the command line interface (CLI). It is the simplest way to become familiar with the ixo Blockchain.
After completing this guide you can run a node on the pandora
testnet.
We recommend the use of Docker and Docker Compose. The configuration files are provided in the ixo-blockchain
directory.
Another way to interact with a node is the ixo MultiClient SDK, instead of CLI.
You will need the following to install and run the ixo
binary:
Optional:
The ixo
binary is named ixod
and serves as the node client and the application client. In other words, the ixo
binary can be used to both run a node and to interact with it.
Clone the ixo
repository:
Change to the ixo-blockchain
directory:
Check out the latest stable version:
Start a session (let's refer to it as session 1
).
Install the ixo
binary.
Check to make sure the installation was successful.
Start the ixo-blockchain
node using pre-configured data.
The script will start the blockchain and create accounts appropriate for the ixo-blockchain
to enable easy interaction. The blocks will progress and you should see the logs to confirm it.
Start another session (let's refer to it as session 2
).
Use the ixod
CLI to query the total bank balances.
You can now interact successfully with the ixo
binary.
Go back to session 1
.
Stop the running node using CTRL
+ C
.
There are two ways to restart the node:
With the same data and continuing from the same block height.
or with the data reset to the first time the node started successfully and from block height 1.
Create a Docker image called ixo-chain
and tagged devel
.
Compose a Docker container.
Start a Bash session (let's refer to it as bash session 1
).
Install the ixo
binary.
Check to make sure the installation was successful.
Start the ixo-blockchain
node using pre-configured data.
Script will start the blockchain and create accounts appropriate for the ixo-blockchain
to enable easy interaction. The blocks will progress and you should see the logs to confirm it.
Start another Bash session (let's refer to it as bash session 2
).
Use the ixod
CLI to query the total bank balances.
You can now interact successfully with the ixo
binary.
Go back to bash session 1
.
Stop the running node using CTRL
+ C
.bash
There are two ways to restart the node:
With the same data and continuing from the same block height.
or with the data reset to the first time the node started successfully and from block height 1.