Files
js/@3rdweb-sdk/react/hooks/useGas.ts
T
Nacho Iacovino 556b4f4a50 Gas estimator (#30)
* Add mapping

* Basic modal with gas price

* Fetch gas price from etherscan

* Only 4 decimals

* Make /gas a page

* Create gas endpoint

* Show USD value

* Built switch

* Linting

* Make ETH the default

* Prettier pls

* Fix styles

* Fix corner

* Border color change

* Add useGas query

* Add defaults

* Fetch data only once

* Use try/catch and promise.all

* Consistent naming

* Move default inside parenthesis

* Use parenthesis

* Prettier pls

* Add undefined to possible type

* Fix error status

* Add key directly to query

* Add links to portal

* Add tooltips

* Add disclaimer

* Add ethereum badge

* Add external link icon

* Make Switch smaller

* Use semantic borderColor
2022-03-30 16:43:33 +02:00

15 lines
261 B
TypeScript

import { useQuery } from "react-query";
export function useGas() {
return useQuery(
["gas-price", "ethereum"],
async () => {
const res = await fetch(`/api/gas`);
return res.json();
},
{
refetchInterval: 10000,
},
);
}