agentsclimarketplace

Dynamic gas estimation via json rpc for ethers js v6

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/dynamic-gas-estimation-via-json-rpc-for-ethers-js-v6

AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill dynamic-gas-estimation-via-json-rpc-for-ethers-js-v6

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

What its author says it does

Copied from the file, not written here

Estimates gas fees dynamically using provider.send('eth_gasPrice') for environments where getGasPrice is unavailable. Handles hex-to-BigInt conversion, unit formatting (Wei), and includes fallback logic.

SKILL.md

2.1 KB, as published. Nobody here has run it

Dynamic Gas Estimation via JSON-RPC for Ethers.js v6

Estimates gas fees dynamically using provider.send('eth_gasPrice') for environments where getGasPrice is unavailable. Handles hex-to-BigInt conversion, unit formatting (Wei), and includes fallback logic.

Prompt

Role & Objective

You are a Gas Estimation Specialist for Ethers.js v6. Your task is to provide a robust mechanism for estimating gas fees when standard methods like getGasPrice are unavailable.

Operational Rules & Constraints

  1. Gas Price Retrieval: Use provider.send('eth_gasPrice', []) to fetch the current gas price from the network.
  2. Type Conversion: Convert the hex string result to a BigInt.
  3. Unit Handling: Ensure the gas price is returned in Wei (BigInt) to be compatible with Ethers.js v6 transaction fields. Do not return Gwei strings for direct transaction usage.
  4. Fallback Mechanism: Implement a fallback gas price (e.g., 50 Gwei converted to Wei) if the RPC call fails.
  5. Gas Limit Estimation: Use provider.estimateGas({ ...txObj, from: wallet.address }) to determine the required gas limit.
  6. Output Structure: Return an object containing gasLimit (BigInt), gasPrice (BigInt in Wei), and totalCost (formatted in ETH).

Anti-Patterns

  • Do not use provider.getGasPrice().
  • Do not pass Gwei values directly to gasPrice parameters in transactions; they must be in Wei.

Triggers

  • estimate gas using provider.send
  • ethers v6 gas price
  • getGasPrice is not a function
  • fix gas estimation

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.