The Witnet decentralized gateway

Rokowski
The Witnet Oracle Blog
4 min readNov 15, 2022

What is it? How does it work? Why is it necessary? What are the future plans?

What is the JSON-RPC gateway?

As we are familiar in this wonderful world of “web3,” deploying a decentralized app on Ethereum mainnet excludes you from potentially millions of people who might want or need to access your dApp. However, EVM compatibility is a wonderful thing in that most blockchains operate on the same or similar execution environments.

The “Web3 RPC” is considered the Swiss army knife of development in this ecosystem, as it makes deploying your unique app to multiple EVM chains incredibly easy. For those who know Witnet on a more technical level, you probably already know where I’m going with this.

The “gateway” is custom built by Witnet and allows for efficient tooling when utilizing the Witnet oracle.

Where are we?

For those less technologically savvy of how Ethereum works, let’s go through a few pieces.

The term JSON-RPC is often floated around, and it isn’t as widely understood as we would like. When an application needs to interact with smart contracts on Ethereum or any EVM compatible chain they need to do it through a specific type of API, which allows for “remote procedure calls” in a JSON format.This is what is referred to as a JSON-RPC.

There are two main types of JSON-RPCs, or nodes that provide this access. Those that give access to wallets, and those that offer read only access. In other words, APIs that locally store private keys and offer the ability to sign transactions and those that only show transaction history and state changes.

Metamask and other wallet browsers like Crypto.com’s, Coinbase, and Opera are operating read only nodes, usually from a 3rd party. While your keys are managed locally (phew), you are utilizing a public node to read the blockchain state and to broadcast recently-signed transactions. Some of these companies include Infura, Ankr, and Alchemy.

What does this mean in Witnet

Now that we’ve covered the bases, we can get into how the “gateway” comes into play.

The gateway in the context of Witnet is a tool that sits between the backend software (the thing that developers use to sign transactions) and a public JSON RPC (how we can broadcast transactions to the network). The application connects to the Witnet gateway and can actually sign transactions on our behalf. Its not as scary as it sounds, in fact its not really scary at all.

The gateway essentially “wraps” a JSONRPC provider in a clear and manageable way, which then intercepts any use of wallet related methods. The largest benefit of the gateway is to call a method on many different EVM chains in exactly the same fashion as you would if you were on Ethereum itself.

For instance in a simple workflow such as sign a transaction:

  1. You give your app on an EVM chain access to the gateway. This allows the gateway to sign transactions on behalf of the application.
  2. The gateway intercepts a JSON RPC http call whilst holding the configuration of the private keys. Anything else will be forwarded to the JSON RPC and will not interact with the gateway any further.
  3. The gateway signs the transaction within the EVM of any compatible chain and forwards it to the JSON-RPC provided by the chain.

So why is this important?

The internally developed gateway is a very strong tool for developers and devops alike.

The first one is a common among many EVM devs, and that is the fact that developers can get compatible RPC endpoints through the localhost on essentially any EVM chain.

The gateway also allows you to set a threshold for gas limits or prices and will filter these transactions out. This can be incredibly helpful for some use cases. Furthermore, the JSON-RPC implemented by Witnet is very user friendly and allows developers to use their favorite web3 tooling, even when a specific chain is built differently; think Conflux, Reef, or Kava. This means developers don’t need to create a case by case basis for deploying a project on a different chain when these chains are built slightly different from the EVM.

Wrapping up

The Witnet network was single built for oracle solutions on any blockchain network. Because of this, the tooling and products needed to be built from the ground up in order to be compatible with not only Witnet, but the places Witnet serves. The gateway is no different. The gateway is an incredibly important tool within Witnet and it is how the chains are able to sync up so incredibly well while still being deterministic and yet still independent of each other.

Connect with Witnet:

Website | GitHub | Twitter | Discord | Telegram | Reddit | YouTube

--

--