# POKT Gateways,ethers.js and Ethereum.

*How to connect to Ethereum using ethers.js powered by POKT*

By [POKT HUB](https://paragraph.com/@pokt-hub) · 2024-06-24

ether.js, gateways, pokt, depin, javascript, nodies, ethereum, json-rpc, grove

---

Ethereum is one of the over 60 chains that is served by [POKT Network](https://www.pokt.network/),a powerful protocol that is your API to the open internet.

To connect to Ethereum over POKT Network we need to use a Gateway.

Gateways in POKT bridge the consumer of services and the suppliers.To consume RPC services that are at the core of POKT protocol one has to go through a gateway.

Gateways are one of the 5 [actors](https://paragraph.xyz/@pokt-hub/pokt-network-actors) of the protocol.

We will learn how to use [ethers.js](https://docs.ethers.org/v6/) to connect to Ethereum using a POKT powered gateway endpoint provided by [Nodies](https://www.nodies.app/) and [Grove](https://www.grove.city/).

See a list of all POKT powered gateways [here](https://poktscan.com/explore?tab=gateways).

Once we have the endpoints ready the next step is to make a connection.

As you'll notice with ether.js the signer and provider are separated.

The provider has read only access to data while signer has authenticated write access backed by a private key.

In our case we will use the provider.

The first step is to use [FetchRequest](https://docs.ethers.org/v6/api/utils/fetching/#FetchRequest) and create a custom request with all the necessary headers and authorization.

For Nodies :-

    let nodiesRequest = new FetchRequest(process.env.nodies_url);
    nodiesRequest.setHeader("x-api-key",process.env.nodies_api_key);
    return nodiesRequest;

For grove:-

    let groveRequest = new FetchRequest(process.env.grove_url);
    groveRequest.setHeader("Content-Type","application/json");
    groveRequest.setHeader("Authorization",process.env.grove_api_key);
    return groveRequest;

As you will notice the function accommodates for different gateways since they all have different methods to authenticate.

Once you have the request set up,you can then use it to instantiate [JsonRpcProvider](https://docs.ethers.org/v6/api/providers/#Provider), a provider that will perform all operations over HTTPs.

    	let _connection = new CreateRequest()._makeRequest('grove');
    	const provider = new ethers.JsonRpcProvider(_connection,1); //1 is Ethereum Chain

Upon the provider being available,you can access the function it exposes,in our case we will check the balance of an address on Ethereum chain.

    let balance = await provider.getBalance(_address);
    return balance;

We have explored how to connect to a POKT powered gateway endpoint.

See complete gist [here](https://gist.github.com/MikeMwambia-TrojanSystem/b155b3ce3dc2ea71248b47c79acd3fbf).

Until next time stay POKT.

---

*Originally published on [POKT HUB](https://paragraph.com/@pokt-hub/connecting-to-pokt)*
