Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/asset-projects/react-hook-evm-fee
- Owner: asset-projects
- License: mit
- Created: 2022-04-06T03:53:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-23T15:33:15.000Z (about 2 years ago)
- Last Synced: 2024-10-06T08:07:54.590Z (about 1 month ago)
- Topics: ethereum, ethers, evm, hooks, react
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/use-evm-fee
- Size: 537 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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) {
returnloading...;
}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