Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/asset-projects/react-hook-evm-fee


https://github.com/asset-projects/react-hook-evm-fee

ethereum ethers evm hooks react

Last synced: 20 days ago
JSON representation

Awesome Lists containing this project

README

        

# use-evm-fee

# Install

```zsh
yarn add ethers
yarn add use-evm-fee
```

## Example

```tsx
import { ethers } from 'ethers';
import { useEVMFeeListener } from 'use-evm-fee';

const App: React.FC = () => {
const { subscribe, network, data } = useEVMFeeListener();

if (!subscribe || !data || !network) {
return

loading...
;
}

const { latestBlock, suggestion, history } = data;

return (


Network


network name: {network.name}


chainId: {network.chainId}

Block


blockNumber: {data.latestBlock.blockNumber}


{`baseFeePerGas: ${ethers.utils.formatUnits(latestBlock.baseFeePerGas, 'gwei')} gwei`}


gasUsedRatio: {latestBlock.gasUsedRatio}


Suggestion


{`baseFeePerGas: ${ethers.utils.formatUnits(suggestion.baseFeePerGas, 'gwei')} gwei`}



{`maxPriorityFeePerGas: ${ethers.utils.formatUnits(
suggestion.maxPriorityFeePerGas,
'gwei',
)} gwei`}


{`maxFeePerGas: ${ethers.utils.formatUnits(suggestion.maxFeePerGas, 'gwei')} gwei`}



History


{history.map((item, index) => (

{JSON.stringify(item)}



))}


);
};
```

# LICENSE

MIT