@web3-onboard/gas
A module for requesting streams or single requests of gas price estimates from the Blocknative Gas Platform API.
Install
NPM
npm i @web3-onboard/gas
Yarn
yarn add @web3-onboard/gas
Standalone Usage
import gas from '@web3-onboard/gas'
const ethMainnetGasBlockPrices = gas.stream({
chains: ['0x1'],
apiKey: '<OPTIONAL_API_KEY>',
endpoint: 'blockPrices'
})
const { unsubscribe: ethGasUnsub } = ethMainnetGasBlockPrices.subscribe(
estimates => console.log(estimates)
)
setTimeout(ethGasUnsub, 10000)
const gasBlockPrices = gas.stream({
chains: ['0x1', '0x89'],
apiKey: '<OPTIONAL_API_KEY>',
endpoint: 'blockPrices',
poll: 1000
})
const { unsubscribe } = gasBlockPrices.subscribe(estimates =>
console.log(estimates)
)
setTimeout(unsubscribe, 10000)
const gasBlockPrices = await gas.get({
chains: ['0x1', '0x89'],
apiKey: '<OPTIONAL_API_KEY>',
endpoint: 'blockPrices'
})