Lava Ethers Provider - ALPHA
Use the Ethers.js, the Lava way 🌋
This repository contains implementations of Ether.js provider using Lava-SDK to achive decentralized access.
(back to top)
Installation
Prerequisites (Alpha version)
SDK setup requires additional steps at the moment, but we're working on minimizing prerequisites as we progress through the roadmap.
- Create a wallet on the Lava Testnet, have LAVA tokens
- Stake in the chain you want to access
- Stake in Lava chain
Need help? We've got you covered 😻 Head over to our Discord channel #developers
and we'll provide testnet tokens and further support
Yarn
yarn add lava-sdk-providers
NPM
npm install lava-sdk-providers
(back to top)
Usage
To use the LavaEthersProvider, you will first need to import and initialize it.
const ethersProvider = await new LavaEthersProvider({
privKey: privKey,
chainID: chainID,
pairingListConfig: localConfigPath,
networkId: networkID,
});
-
privateKey
parameter is required and should be the private key of the staked Lava client for the specified chainID
.
-
chainID
parameter is required and should be the ID of the chain you want to query. You can find all supported chains with their IDs supportedChains
-
pairingListConfig
is an optional field that specifies the lava pairing list config used for communicating with lava network. Lava SDK does not rely on one centralized rpc for querying lava network. It uses a list of rpc providers to fetch list of the providers for specified chainID
and rpcInterface
from lava network. If not pairingListConfig set, the default list will be used default lava pairing list
-
networkId
represents chain id of the network we want to query. By default every supported chain has matching chain id (https://github.com/lavanet/lava-sdk-providers/blob/main/ethersjs/supportedChains.json)
Once the LavaEthersProvider is initialized, you can use any method provided by the Ether.js library to interact with the blockchain. For example, to get the latest block number, you can use the following code:
const blockNumber = await ethersProvider.getBlockNumber();
This will return the block number of the latest block on the specified chain. You can find more information on available methods in the official Ether.js documentation
(back to top)