estimate_gas_savings
Calculate gas savings for token deployments using a paymaster to reduce transaction costs on Base network.
Instructions
Show how much gas was saved (or would be saved) by using the paymaster for a token deployment.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token_address | Yes | Token contract address to check gas savings for |
Implementation Reference
- src/index.ts:274-320 (handler)The implementation handler for the estimate_gas_savings tool.
async ({ token_address }) => { try { const provider = getProvider(); // Check if we have a deploy record const record = deployments.find( (d) => d.tokenAddress.toLowerCase() === token_address.toLowerCase() ); // Get current gas prices for estimation const feeData = await provider.getFeeData(); const gasPrice = feeData.gasPrice || 0n; // Typical ERC-20 deploy gas: ~700k-1M gas units // Use actual if we have it, otherwise estimate const gasUsed = record ? BigInt(record.gasUsed) : 850000n; const estimatedCostWei = gasUsed * gasPrice; const estimatedCostEth = ethers.formatEther(estimatedCostWei); // Get ETH price estimate (rough) const ethPriceUsd = 2500; // Approximate const result: Record<string, unknown> = { token_address, gas_units_used: gasUsed.toString(), current_gas_price_gwei: ethers.formatUnits(gasPrice, "gwei"), estimated_cost_eth: estimatedCostEth, estimated_cost_usd: `$${(parseFloat(estimatedCostEth) * ethPriceUsd).toFixed(4)}`, eth_price_estimate_usd: ethPriceUsd, paymaster_configured: isPaymasterEnabled(), }; if (record) { result.actual_gas_used = record.gasUsed; result.actual_gas_cost_wei = record.gasCostWei; result.actual_gas_cost_eth = ethers.formatEther(BigInt(record.gasCostWei)); result.used_paymaster = record.usedPaymaster; result.gas_saved_eth = record.usedPaymaster ? ethers.formatEther(BigInt(record.gasCostWei)) : "0"; result.gas_saved_usd = record.usedPaymaster ? `$${(parseFloat(ethers.formatEther(BigInt(record.gasCostWei))) * ethPriceUsd).toFixed(4)}` : "$0"; result.status = record.usedPaymaster ? "Gas was fully sponsored by paymaster" : "Gas was paid by deployer (paymaster not used)"; } else { - src/index.ts:268-273 (registration)The registration of the estimate_gas_savings tool.
server.tool( "estimate_gas_savings", "Show how much gas was saved (or would be saved) by using the paymaster for a token deployment.", { token_address: z.string().describe("Token contract address to check gas savings for"), },