feat: Gas Estimation Agent for multi-chain cost comparison#21
Open
dagangtj wants to merge 1 commit intoPayPol-Foundation:mainfrom
Open
feat: Gas Estimation Agent for multi-chain cost comparison#21dagangtj wants to merge 1 commit intoPayPol-Foundation:mainfrom
dagangtj wants to merge 1 commit intoPayPol-Foundation:mainfrom
Conversation
Implements issue PayPol-Foundation#7 - Gas Estimation Agent Features: - Multi-chain gas price queries (Tempo L1, Ethereum, Arbitrum, Base) - Real-time gas costs in gwei and USD equivalent - Cost estimation for common operations (transfer, ERC-20, deploy) - Smart chain recommendation based on cost - 15-second result caching for performance - RPC failure handling with fallback providers Acceptance criteria fulfilled: ✅ Queries gas prices from 4+ chains ✅ Returns costs in native units and USD ✅ Estimates common operation costs ✅ Provides cheapest chain recommendation ✅ Configurable TTL caching (15s) ✅ Graceful RPC failure handling ✅ PayPol marketplace SDK integration Closes PayPol-Foundation#7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR implements a Gas Estimation Agent that compares real-time gas costs across Tempo L1, Ethereum, Arbitrum, and Base, helping users choose the most cost-effective chain for their transactions.
Closes
Closes #7
Features
✅ Multi-chain support: Tempo L1, Ethereum, Arbitrum, Base
✅ Real-time gas prices in gwei and USD equivalent
✅ Cost estimation for common operations:
✅ Smart recommendations for cheapest chain
✅ 15-second caching for performance
✅ RPC fallback handling for reliability
Example Response
{ "operation": "ERC-20 Transfer", "estimates": [ {"chain": "Tempo L1", "gasPrice": "0.00 gwei", "cost": "$0.0000", "speed": "1s"}, {"chain": "Base", "gasPrice": "0.02 gwei", "cost": "$0.0039", "speed": "2s"}, {"chain": "Arbitrum", "gasPrice": "0.05 gwei", "cost": "$0.0098", "speed": "2s"}, {"chain": "Ethereum", "gasPrice": "25.00 gwei", "cost": "$4.8750", "speed": "12s"} ], "recommendation": "Tempo L1 has zero gas fees with fast finality (1s). Highly recommended for cost-sensitive operations." }Acceptance Criteria
All requirements from issue #7 fulfilled:
Testing
cd agents/gas-estimator npm install npm run devTest endpoints:
GET /health- Health checkGET /manifest- Agent metadataPOST /execute- Run gas estimationImplementation Details
Files Changed
agents/gas-estimator/src/index.ts- Main agent logicagents/gas-estimator/src/register.ts- Marketplace registrationagents/gas-estimator/package.json- Dependenciesagents/gas-estimator/README.md- Documentationagents/gas-estimator/.env.example- Configuration template