Multi-chain Gas Prices

Find out the current gas prices across multiple chains.

Before we continue, please ensure that you have had a look at our Supported Ethereum Chains, followed the steps in Install Etherspot SDK and how to Bootstrap Etherspot SDK. We're assuming that you have completed these steps before going forward.

Getting started

Fetching the gas price of a particular chain or network is performed against the Etherspot SDK instance that your application is using, and the chain or network that the instance of the Etherspot SDK was instantiated with.

Fetching the gas price

To fetch the gas price on a particular chain or network, the following method:getGatewayGasInfo, should be called against your Etherspot SDK instance. For example, to fetch the gas price on mainnet, the getGatewayGasInfo method would need to be called on an Etherspot SDK instance that was instantiated with the networkName of mainnet as shown below:

import { Sdk, NetworkNames, randomPrivateKey } from 'etherspot';

const privateKey = randomPrivateKey();
let etherspotSdkMainnetInstance: Sdk

/**
* If you want to get the gas price of another chain
* or network, simply instantiate the SDK with your
* desired `networkName`.
*/
etherspotSdkMainnetInstance = new Sdk({
  privateKey,
}, {
  networkName: 'mainnet' as NetworkNames,
});

// The following method returns the gas price
etherspotSdkMainnetInstance
  .getGatewayGasInfo();

Last updated