gasprice-tracker-ethereum
v1.0.0
Published
A utility library for Ethereum gas price tracking and some basic utils.
Downloads
13
Readme
gasprice-tracker-ethereum
gasprice-tracker-ethereum is a lightweight Node.js module that provides real-time gas price estimates and network information using public Ethereum RPC endpoints. It requires no API keys, ensuring a hassle-free setup.
🚀 Features
- Fetch current gas prices (Low, Medium, High) without API keys.
- Get the latest Ethereum block number.
- Retrieve overall network information including block number and gas prices.
- Lightweight and efficient, using only public RPC nodes.
- No third-party API dependencies.
📦 Installation
npm install gasprice-tracker-ethereum🚀 Usage
const { estimateGasPrices, getBlockNumber, getNetworkInfo } = require('gasprice-tracker-ethereum');
(async () => {
const gasPrices = await estimateGasPrices();
console.log("Estimated Gas Prices (Gwei):", gasPrices);
const blockNumber = await getBlockNumber();
console.log("Current Block Number:", blockNumber);
const networkInfo = await getNetworkInfo();
console.log("Network Info:", networkInfo);
})();📚 Methods
estimateGasPrices()
Fetches gas prices in Gwei for different priority levels:
- Low: 90% of the median gas price.
- Medium: Current median gas price.
- High: 110% of the median gas price.
getBlockNumber()
Retrieves the latest Ethereum block number.
getNetworkInfo()
Returns an object containing the latest block number and gas prices.
🔥 Error Handling
If the public RPC provider is down or rate-limited, the functions return null values and log errors to the console.
🐛 Reporting Issues
If you encounter any issues, please open an issue.
🛠 Contributing
- Fork the repository.
- Create a new branch:
git checkout -b feature-branch. - Commit your changes:
git commit -m 'Add new feature'. - Push to the branch:
git push origin feature-branch. - Submit a pull request.
📄 License
This project is licensed under the MIT License.
