Hooks
useGas

useGas

Hook for returning the current gas price.

import { useGas } from "aptosjs"

Usage

import { useGas } from "aptosjs"
 
function App(){
  const { data, loading, error } = useGas({
    network: "mainnet"
  })
 
  if (loading) return <p>Loading...</p>
  if (error) return <p>Error: {error}</p>
  return <p>Gas: {data?.gas}</p>
}

Example Return

To format the gas number in terms of APT, divide by 100000000.

{
  deprioritized: 100,
  gas: 100,
  prioritized: 150
}

Input Values

{
  network: "mainnet" | "testnet" | "devnet"
}

Network (required)

The Aptos network to get info from.

network: "mainnet" | "testnet" | "devnet"

Return Values

{
  deprioritized: int,
  gas: int, 
  prioritized: int 
}