Skip to content

πŸš€ Powerful PHP library for retrieving live Ethereum gas prices ⛽️. Optimize transactions and smart contracts with up-to-date gas price data. πŸ’ͺ

License

Notifications You must be signed in to change notification settings

numairawan/eth-gas-tracker-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c9bb05b Β· Sep 27, 2023

History

14 Commits
Jul 15, 2023
Jul 15, 2023
Sep 26, 2023
Jul 15, 2023
Jul 15, 2023
Sep 27, 2023
Jul 16, 2023

Repository files navigation

Eth Gas Tracker PHP

Total Downloads Latest Version License


eth-gas-tracker-php is a powerful PHP library that provides developers with an effortless way to retrieve live Ethereum gas prices, empowering them to optimize transactions and smart contracts on the Ethereum network.

Features

  • πŸš€ Retrieve live Ethereum gas prices with ease.
  • ⛽️ Obtain up-to-date and accurate gas price data.
  • πŸ’ͺ Fine-tune transaction optimization based on real-time gas prices.
  • 🀝 Seamless integration into existing PHP projects.
  • πŸ“š Comprehensive documentation and code examples for easy implementation.

Installation

To install the library, you can use Composer and run the following command:

composer require numairawan/eth-gas-tracker-php

Usage

To retrieve live Ethereum gas prices, follow these simple steps:

use NumairAwan\EthGasTracker\EthereumGasPrice;

// Instantiate the EthereumGasPrice
$ethereumGasPrice = new EthereumGasPrice();

// Get gas prices
$gasPrice = $ethereumGasPrice->getGasPrices();

// safe gas price 
echo "Gas Prices:\n";
echo "Slow Gas Price: " . $gasPrice->proposeGas . " Gwei\n";
echo "Safe Gas Price: " . $gasPrice->safeGas . " Gwei\n";
echo "Fast Gas Price: " . $gasPrice->fastGas . " Gwei\n";

Utilities

// Convert gas prices to Wei
$fastGasPriceWei = $ethereumGasPrice->toWei($gasPrice->fastGas);
echo "Fast Gas Price (Wei): " . $fastGasPriceWei . PHP_EOL;

// Convert gas prices (WEI) to Hexadecimal with '0x' prefix (don't pass second parameter to just get hex)
$fastGasPriceHex = $ethereumGasPrice->toHex($fastGasPriceWei, true);
echo "Fast Gas Price (Hex): " . $fastGasPriceHex . PHP_EOL;

Contributing

Contributions are welcome! Feel free to fork the repository and submit pull requests as well.

License

This project is licensed under the MIT license.

Connect with Me

Feel free to reach out to me for any project-related queries or collaborations. I'm always happy to connect and discuss ideas!

Telegram WhatsApp