numairawan / eth-gas-tracker-php
用于检索实时以太坊燃气价格的强大PHP库。
v2.0.0
2023-09-26 23:34 UTC
README
eth-gas-tracker-php 是一个强大的PHP库,为开发者提供了一种轻松检索实时以太坊燃气价格的方式,使他们能够优化以太坊网络上的交易和智能合约。
功能
- 🚀 轻松检索实时以太坊燃气价格。
- ⛽️ 获取最新和准确的燃气价格数据。
- 💪 根据实时燃气价格调整交易优化。
- 🤝 无缝集成到现有的PHP项目中。
- 📚 提供全面的文档和代码示例,易于实现。
安装
要安装此库,您可以使用 Composer 并运行以下命令
composer require numairawan/eth-gas-tracker-php
用法
要检索实时以太坊燃气价格,请按照以下简单步骤操作
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";
实用工具
// 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;
贡献
欢迎贡献!您可以随意fork存储库并提交pull请求。
许可
本项目采用 MIT许可。
与我联系
对于任何项目相关的问题或合作,请随时与我联系。我总是很高兴与您交流并讨论想法!