JSON-RPC vs gRPC: understanding RPC protocols in blockchain

GoldRush TeamUpdated 14 min read

JSON-RPC is JSON over HTTP or WebSocket. gRPC is Protobuf over HTTP/2 with streaming. How they differ, which chains use each, and code for both.

Choose JSON-RPC when you want the standard interface every Ethereum and Solana node and library already speaks: plain JSON you can send with curl. Choose gRPC when you control both ends and need typed, generated clients, small binary messages and long-lived streams, as Solana's Yellowstone plugin, the Cosmos SDK and Sui offer.

Aspect JSON-RPC gRPC
What it is A small specification for request and response objects A framework: service definitions, generated code, transport and tooling
Message format JSON text Protocol Buffers (binary) by default
Transport Any: HTTP POST and WebSocket in blockchain HTTP/2
Schema None in the protocol; each chain documents its methods Required: a .proto file defines every service and message
Client code Hand-written, or a chain library (viem, ethers, web3.py, @solana/kit) Generated from the .proto by protoc for each language
Streaming Request and response; chains add subscriptions over WebSocket Server, client and bidirectional streams are built in
Batching Send an array of requests, get an array of responses One call per RPC; streams replace most batching
Browsers Works anywhere fetch works Needs gRPC-Web and a proxy such as Envoy
Debugging Readable with curl and logs Needs the .proto or server reflection, and a tool such as grpcurl
Auth Not in the spec: HTTPS plus a key in a header or URL TLS channel credentials plus per-call metadata (tokens)
Blockchain use Ethereum and every EVM chain, Solana, CometBFT Solana Yellowstone (Geyser), Cosmos SDK, Sui full nodes

JSON-RPC overview

JSON-RPC 2.0 is a stateless, lightweight remote procedure call protocol. Its specification defines only a few JSON objects and the rules for processing them, and it is transport agnostic: the same messages can travel over HTTP, a WebSocket, a raw socket or inside one process.

A request names a method, passes params and carries an id. The server answers with an object that has the same id and either a result or an error:

{ "jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber", "params": [] }
{ "jsonrpc": "2.0", "id": 1, "result": "0x193a201" }

That is how blockchain nodes expose themselves to wallets, dapps and indexers. Every Ethereum execution client implements the same Ethereum JSON-RPC API, so eth_getBalance or eth_call work the same against any node or provider. Solana nodes serve their own method set (getSlot, getAccountInfo, sendTransaction and so on) as JSON-RPC over HTTP, plus subscriptions such as accountSubscribe over a WebSocket.

Aspects of JSON-RPC

  • Request and response. The client sends a request object; the server replies with a response object matched by id.
  • Notifications. A request without an id is a notification. The server must not reply to it.
  • Batches. The client can send an array of requests in one message. The server returns an array of responses, in any order, which the client matches by id.
  • Errors. Failures come back as an error object with a numeric code and a message. The spec reserves codes such as -32700 (parse error), -32600 (invalid request), -32601 (method not found) and -32602 (invalid params).
  • No schema. The protocol says nothing about which methods exist or what their parameters look like. Each chain documents that itself. Ethereum, for example, encodes numbers as 0x-prefixed hex strings and lets you pick a block with a number or a tag (latest, safe, finalized, earliest, pending).
  • No transport or security rules. Encryption, authentication and rate limits come from whatever carries the messages, usually HTTPS.

gRPC overview

gRPC is an open-source RPC framework, originally from Google, in which a client calls methods on a remote server as if it were a local object. You define a service and its messages in a .proto file using Protocol Buffers, and the protoc compiler generates client stubs and server interfaces for each language you use. The server implements the interface; clients call the generated stub.

gRPC runs over HTTP/2, and its core concepts include four kinds of method:

  • Unary: one request, one response, like a JSON-RPC call.
  • Server streaming: one request, then a stream of responses, such as every new block or account update.
  • Client streaming: the client sends a stream, the server answers once.
  • Bidirectional streaming: both sides send streams independently over one call.

Every call can carry a deadline, after which it fails with DEADLINE_EXCEEDED, and metadata: key-value pairs sent like headers, which is where tokens and other per-call context go. The trade-offs are a learning curve around Protobuf, binary messages you can't read without the schema, and browsers: they can't make native gRPC calls, so web apps use gRPC-Web through a proxy such as Envoy, or a REST gateway.

Comparing JSON-RPC and gRPC

Transport

JSON-RPC doesn't specify a transport. In blockchain it almost always means an HTTP POST to an endpoint URL, or JSON messages over a WebSocket when you want subscriptions. gRPC is defined on top of HTTP/2: each call is an HTTP/2 stream with content-type: application/grpc, which lets many calls share one connection and lets either side keep sending messages for as long as the call is open.

Serialization

JSON is text: self-describing, readable, and larger. Protobuf is binary and depends on the schema: field names are replaced by field numbers, and integers are packed as variable-length bytes. The Protobuf docs describe it as like JSON but smaller and faster, and also note where it is not a good fit, such as messages larger than a few megabytes.

Schema and code generation

With JSON-RPC, the method list lives in documentation and in chain libraries such as viem, ethers, web3.py or @solana/kit, which wrap each method in a typed function. With gRPC, the .proto file is the contract: the client and server code are generated from the same file, so a renamed field or a wrong type shows up when you compile, not at runtime. Protobuf also lets you add fields without breaking older clients, as long as field numbers aren't reused.

Authentication and security

The JSON-RPC spec has no authentication. Hosted endpoints rely on HTTPS and an API key, either in the URL path (the pattern many RPC providers use) or in a header. gRPC has authentication built in: TLS channel credentials for the connection, and per-call credentials such as tokens sent as metadata. Yellowstone gRPC servers, for example, read an x-token metadata value, and Cosmos SDK nodes read an x-cosmos-block-height metadata value to answer a query at a past block.

Performance

gRPC's advantages come from three places, and none of them is automatic.

  • Smaller messages. For the same question, "what is the latest finalized slot?", Solana's JSON-RPC getSlot request is 81 bytes and its response 43 bytes. The equivalent Yellowstone gRPC GetSlot request encodes to 2 bytes of Protobuf and its response to 6 bytes. We counted these on 22 November 2026: the JSON bodies as compact JSON.stringify output, the Protobuf messages encoded with protobufjs 7.6.6 from geyser.proto (tag v17.0.2+solana.4.4.1), both for a nine-digit slot such as 400,000,000. Both still travel with HTTP headers, and gRPC adds a 5-byte prefix to each message, so the gain matters most when you move many messages or large ones.
  • Cheaper parsing. Decoding binary fields by number is less work than parsing JSON text and converting hex strings to integers. It shows up in high-volume consumers such as indexers, not in a wallet making a few calls.
  • Push instead of poll. The biggest practical difference in blockchain. A JSON-RPC client that wants every new block polls eth_blockNumber, or opens a WebSocket subscription where the chain offers one. A gRPC server stream pushes each update as it happens, on one connection, with the server filtering what you asked for.

JSON-RPC is not limited to one request at a time: batches send many requests in one message, and a client can keep several HTTP connections open. If your workload is occasional reads and transaction submission, the network round trip dominates and the protocol makes little difference. Measure your own workload before you switch.

Use cases

JSON-RPC fits:

  • Wallets and dapps that read balances, call contracts and submit transactions on Ethereum, EVM chains or Solana.
  • Anything that should work with the standard libraries and any node or provider, without a schema to distribute.
  • Browser apps, scripts and quick debugging with curl.
  • Smart contract development and testing, where local nodes and frameworks talk JSON-RPC.

gRPC fits:

  • Indexers and trading systems that consume every account update, transaction or slot on Solana in real time, through a Yellowstone (Geyser) gRPC stream.
  • Backends on Cosmos SDK chains, where every module's queries are Protobuf services.
  • Sui backends and indexers: Sui's full node API is now gRPC, with GraphQL for frontends.
  • Internal services you own on both ends, where generated, typed clients and streams pay off.

How blockchains use each protocol

Chain JSON-RPC gRPC
Ethereum and EVM chains The standard node interface, the Ethereum JSON-RPC API Not part of the standard node interface
Solana The Solana RPC over HTTP, plus WebSocket subscriptions Yellowstone gRPC, a Geyser plugin run on validators and RPC nodes for streaming
Cosmos SDK chains CometBFT's RPC server, JSON-RPC over HTTP and WebSocket (port 26657 by default) The Cosmos SDK gRPC server (port 9090), with REST routes generated by gRPC-gateway (port 1317)
Sui Disabled on Sui Foundation mainnet full nodes since the week of 27 July 2026 The full node gRPC API, alongside GraphQL RPC

Two trends stand out. Solana kept JSON-RPC as its client interface and added gRPC for high-volume streaming. Sui went further: its RPC docs tell anyone still calling JSON-RPC to migrate to gRPC or GraphQL RPC.

Calling a JSON-RPC endpoint

Here is eth_blockNumber against the GoldRush JSON-RPC endpoint for Ethereum. GoldRush takes the API key in an Authorization header rather than in the URL; the request body is standard JSON-RPC, so the same body works against any Ethereum node.

To run the examples you need a GoldRush API key in the GOLDRUSH_API_KEY environment variable and, for the JavaScript, Node.js 18 or later. The JavaScript uses top-level await and import, so save each script as a .mjs file (for example rpc.mjs) and run it with node rpc.mjs.

curl https://rpc.goldrushdata.com/v1/eth-mainnet \  -H "Authorization: Bearer $GOLDRUSH_API_KEY" \  -H "Content-Type: application/json" \  -d '{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber","params":[]}' # The response has this shape (the block number is illustrative):# {"jsonrpc":"2.0","id":1,"result":"0x193a201"}

The same call from JavaScript, then a batch of two methods in one request. Save it as rpc.mjs:

const URL = "https://rpc.goldrushdata.com/v1/eth-mainnet"; async function rpc(body) {  const res = await fetch(URL, {    method: "POST",    headers: {      "Content-Type": "application/json",      Authorization: `Bearer ${process.env.GOLDRUSH_API_KEY}`,    },    body: JSON.stringify(body),  });  return res.json();} // One call: the result is a hex quantity such as "0x193a201".const { result, error } = await rpc({ jsonrpc: "2.0", id: 1, method: "eth_blockNumber", params: [] });if (error) throw new Error(`${error.code}: ${error.message}`);console.log("latest block:", Number(BigInt(result))); // A batch: an array of requests, answered by an array you match on id.const replies = await rpc([  { jsonrpc: "2.0", id: 1, method: "eth_blockNumber", params: [] },  { jsonrpc: "2.0", id: 2, method: "eth_chainId", params: [] },]);// A failed request (no key, no credits) answers with one error object, not an array.if (!Array.isArray(replies)) throw new Error(`${replies.error?.code}: ${replies.error?.message}`);const byId = Object.fromEntries(replies.map((r) => [r.id, r.result]));console.log("block", Number(BigInt(byId[1])), "on chain", Number(BigInt(byId[2])));

In production you would usually hand the endpoint to a library instead: the JSON-RPC quickstart shows viem, ethers, web3.js and web3.py with the header set.

Handle errors from GoldRush JSON-RPC

GoldRush returns authentication and credit failures as a standard JSON-RPC error object. Sent with no key, or a made-up one, on 22 November 2026, the endpoint answered with HTTP 200 and this body:

{  "jsonrpc": "2.0",  "error": {    "code": -32600,    "message": "missing or malformed api key",    "data": null  }}

It means the key never reached GoldRush, or not in the form it expects. Check that GOLDRUSH_API_KEY is set in the shell that runs the script and that the header reads Authorization: Bearer <key>. The error check in rpc.mjs turns this body into an exception, -32600: missing or malformed api key; the body has no id, and a batch gets the same single object, which is why rpc.mjs checks for an array. The authentication docs describe the missing-key case as HTTP 401 with code -32001 ("missing or invalid Authorization header"), so check the error field rather than the HTTP status. The docs list these failures:

HTTP JSON-RPC code Meaning What to do
401 Unauthorized -32001 Missing or malformed Authorization header Send Authorization: Bearer <key>
403 Forbidden -32002 The key is valid but has no JSON-RPC access Ask support to enable JSON-RPC
402 Payment Required -32003 Not enough credits Top up your credit balance
429 Too Many Requests -32005 Rate limit exceeded Back off and retry after Retry-After

Errors from the method itself, such as -32601 for an unknown method or -32602 for bad parameters, use the reserved codes from the JSON-RPC specification described in Aspects of JSON-RPC.

Calling a gRPC endpoint

A gRPC call starts from the service definition. This excerpt is from geyser.proto in the Yellowstone gRPC repository, at tag v17.0.2+solana.4.4.1: the whole Geyser service, with a bidirectional Subscribe stream for slots, accounts, transactions and blocks and unary methods such as GetSlot, plus the messages GetSlot uses. It is for reading; download the complete files with the commands below rather than copying it.

syntax = "proto3";package geyser; service Geyser {  rpc Subscribe(stream SubscribeRequest) returns (stream SubscribeUpdate) {}  rpc SubscribeDeshred(stream SubscribeDeshredRequest) returns (stream SubscribeUpdateDeshred) {}  rpc SubscribeGossip(SubscribeGossipRequest) returns (stream SubscribeUpdateGossip) {}  rpc SubscribeReplayInfo(SubscribeReplayInfoRequest) returns (SubscribeReplayInfoResponse) {}  rpc Ping(PingRequest) returns (PongResponse) {}  rpc GetLatestBlockhash(GetLatestBlockhashRequest) returns (GetLatestBlockhashResponse) {}  rpc GetBlockHeight(GetBlockHeightRequest) returns (GetBlockHeightResponse) {}  rpc GetSlot(GetSlotRequest) returns (GetSlotResponse) {}  rpc IsBlockhashValid(IsBlockhashValidRequest) returns (IsBlockhashValidResponse) {}  rpc GetVersion(GetVersionRequest) returns (GetVersionResponse) {}} enum CommitmentLevel {  PROCESSED = 0;  CONFIRMED = 1;  FINALIZED = 2;} message GetSlotRequest {  optional CommitmentLevel commitment = 1;} message GetSlotResponse {  uint64 slot = 1;}

With Node.js, @grpc/proto-loader reads the .proto files (geyser.proto and the solana-storage.proto it imports) and @grpc/grpc-js builds a client from them at runtime. The endpoint and token come from whichever provider runs Yellowstone for you; GoldRush doesn't offer a gRPC endpoint. Install the two packages and download both files from the same tag into ./proto:

npm install @grpc/grpc-js@1.14.7 @grpc/proto-loader@0.8.1mkdir -p protoBASE="https://raw.githubusercontent.com/rpcpool/yellowstone-grpc/v17.0.2%2Bsolana.4.4.1/yellowstone-grpc-proto/proto"curl -fsSL -o proto/geyser.proto "$BASE/geyser.proto"curl -fsSL -o proto/solana-storage.proto "$BASE/solana-storage.proto"

Then save this as slot.mjs, set YELLOWSTONE_ENDPOINT (host and port) and YELLOWSTONE_TOKEN, and run node slot.mjs:

import grpc from "@grpc/grpc-js";import protoLoader from "@grpc/proto-loader"; // geyser.proto and solana-storage.proto from github.com/rpcpool/yellowstone-grpc (tag v17.0.2+solana.4.4.1), in ./protoconst definition = protoLoader.loadSync("geyser.proto", {  includeDirs: ["proto"],  longs: String,  enums: String,});const { geyser } = grpc.loadPackageDefinition(definition); const client = new geyser.Geyser(process.env.YELLOWSTONE_ENDPOINT, grpc.credentials.createSsl());const metadata = new grpc.Metadata();metadata.set("x-token", process.env.YELLOWSTONE_TOKEN); client.GetSlot({ commitment: "FINALIZED" }, metadata, (err, res) => {  if (err) throw err;  console.log("finalized slot:", res.slot);  client.close();});

longs: String returns the uint64 slot as a string, since JavaScript numbers can't hold every 64-bit value. If the call fails, err carries the gRPC status code and message instead of a response, and the callback rethrows it. The JSON-RPC version of the same question is Solana's getSlot with {"commitment":"finalized"}, which returns the slot as a plain JSON number.

Integration strategies

You rarely have to pick one protocol for a whole system.

  • Use both, by job. Read state and send transactions over JSON-RPC, and run a gRPC stream only in the service that needs every update. That is the common pattern on Solana.
  • Put a gateway in front of gRPC. The Cosmos SDK serves every gRPC query as REST through gRPC-gateway, and gRPC-Web with a proxy lets browsers call gRPC services. Clients keep their simple interface while the backend stays typed.
  • Keep the .proto files in version control and generate clients in your build, so every service uses the same contract. Add fields with new numbers; never reuse or renumber old ones.
  • Migrate incrementally. If a chain retires JSON-RPC, as Sui has, move one call path at a time and compare responses from the old and new interfaces before switching over.

Frequently asked questions

What is the difference between JSON-RPC and gRPC?

JSON-RPC is a small protocol for sending method calls as JSON objects over any transport, usually HTTP or WebSocket. gRPC is a framework that sends Protocol Buffers messages over HTTP/2, generates typed clients from a .proto schema and supports streaming in both directions.

Is gRPC faster than JSON-RPC?

Usually for high-volume work: Protobuf messages are smaller and cheaper to parse than JSON, and gRPC streams push updates instead of making clients poll. For a few reads or a transaction submission, network latency dominates and the difference is small, so measure your own workload.

Does Ethereum support gRPC?

Ethereum's standard node interface is the JSON-RPC API that every execution client implements, so wallets, libraries and providers use JSON-RPC. gRPC is not part of that standard interface.

Does Solana use gRPC or JSON-RPC?

Both. Solana's client interface is JSON-RPC over HTTP with WebSocket subscriptions. For high-volume streaming of slots, accounts and transactions there is Yellowstone gRPC, a Geyser plugin built by Triton One that validators and RPC providers run to serve that data over gRPC streams.

Can a browser call a gRPC API?

Not directly: browsers don't expose the HTTP/2 control gRPC needs. Web apps use gRPC-Web through a proxy such as Envoy, or a REST gateway in front of the gRPC service, as the Cosmos SDK provides.

Does GoldRush offer JSON-RPC or gRPC?

GoldRush offers JSON-RPC: standard Ethereum-style methods on EVM chains, including archive, debug and trace methods, and the Solana method set with WebSocket subscriptions, on the same API key as its other APIs. It doesn't offer a gRPC endpoint.

Next steps

Get new guides by email

New tutorials and best practices for building with blockchain data, sent as they're published.