Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add reference doc: Comparison of ways to communicate with Gno.land #2324

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions docs/reference/comparison-of-ways-to-interact-with-gnoland.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
id: comparison-of-ways-to-interact-with-gnoland
---

# 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](https://github.com/gnolang/gno/tree/master/tm2/pkg/amino) 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`](https://docs.gno.land/how-to-guides/connect-from-go) and [`crypto/keys`](https://github.com/gnolang/gno/tree/master/tm2/pkg/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 crypto keys and managing the local keys database.

Make sure you also check out this [practical guide](https://github.com/gnolang/gno/blob/master/docs/how-to-guides/connecting-from-go.md) on connecting from Go using gnoclient.

**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](https://github.com/gnolang/gnonative) 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](https://github.com/gnolang/tm2-js-client) is a JavaScript/TypeScript client implementation for Tendermint2-based chains (such as Gno.land). [gno-js](https://github.com/gnolang/gno-js-client/blob/main/README.md) 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](https://github.com/gnolang/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.

---
title: Comparison of ways to interact with gnoland

---



| | 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) |
Loading