Comparison of the various ways to communicate with Gno.land
This document is an overview of the various methods to interact with gnoland. This is mainly for developers writing applications.
JSON-RPC
What is it? The RPC interface is the base-level method to interact with the gno.land blockchain over an HTTP-RPC connection. The actual RPC messages are encoded in Protocol Buffers binary wire format (as used by Protobuf).
When to use it? The HTTP-RPC interface is used under-the-hood by gnokey
and all the other methods. Some of the messages are simple and your app could open an HTTP connection and interact with the blockchain. But most Protobuf messages are more complex and you would want to use one of the following methods.
gRPC clients generated by Protobuf
What is it? The core Gno codebase uses the light-weight Amino package to format the Protobuf messages when interacting with the blockchain. Another method is to use a Protobuf library to format the messages.
When to use it? Amino is a Go package, so you can't use it if your app is written in a different programming language. Instead, you can import a Protobuf library to format and parse the messages for interacting with the blockchain.
Go code with gnoclient
and crypto/keys
What is it? The gnoclient
and crypto/keys
packages are part of the core Gno codebase, written in Go. The gnoclient
API is for querying the blockchain, calling realm functions, and other basic interactions. The crypto/keys
API is for generating cryptographical keys and managing the local keys database.
When to use it? If your app is written in Go, you can use these packages (as gnokey
and other command-line apps do).
Gno Native Kit
What is it? Gno Native Kit is a framework that allows developers to build and port gno.land dApps written in the dApp's native language such as TypeScript, Java or C#. It is a wrapper on top of the gnoclient
and crypto/keys
which allows your app to use the functionality in these core Gno packages.
When to use it? If your app is not written in Go (for example, React Native on mobile), then Gno Native Kit can provide access to all the functionality.
tm2-js / gno-js
What is it? tm2-js is a JavaScript/TypeScript client implementation for Tendermint2-based chains (such as Gno.land). gno-js is an extension of tm2-js, but with Gno-specific functionality.
gno-js is designed to make it easy for developers to interact with the Gno.land blockchain by providing a simplified API for account and transaction management.
When to use it? When developing a browser app without access to the Go runtime (which is used by all the other methods).
tx-indexer
with GraphQL
What is it? tx-indexer is a tool which makes an indexed database of the transactions on the gno.land blockchain. It comes with a GraphQL interface which you can use directly in a web page or from your app through WebSocket.
When to use it? If your app needs to do CPU-intensive processing of your realm data, then it is better to have a dedicated service running on a server instead of on-chain processing. tx-indexer
provides efficient read-only queries of just the data that needs to be processed. Then your end-user app can fetch the result from the service.
JSON-RPC | gRPC clients generated by Protobuf | Go code with gnoclient crypto/keys | Gno Native Kit | tm2-js / gno-js | tx-indexer with GraphQL | |
---|---|---|---|---|---|---|
App programing language | Any language with an HTTP library | Go, JavaScript, Java, Swift, C#, more supported by gRPC | Go | Go, JavaScript, Java, Swift, C#, more supported by gRPC | JavaScript | Any language with a WebSocket library |
Platform | Any constrained platform where you can't use any of the other methods | Any platform that has a Protobuf library | Desktop utilities | Mobile, desktop apps | Browser | Off-chain service apps |
Uses core Gno code? | No | No | Yes | Yes | No | Yes |
Requires programming in Protobuf? | No | No | Yes | Yes | Yes | Yes |
Supports browser applications | Yes | No | No | No | No | N/A |
Recommended for | Situations where you can't use any of the other methods due to significant constraints. (e.g. a Raspberry Pi querying the blockchain for an account balance) | Apps which can't link to the core Go code | Basic Go apps (like command-line utils) | Robust mobile and desktop apps where devs use gRPC to bypass the complexity of interacting directly with the blockchain | Browser apps | Complex read-only interactions (e.g.: compute the home feed of a dApp) |