Comments (6)
Gas estimation continues to be an issue on optimism for us. We will likely need to move away from Hop as a result unfortunately
from hop.
The reason for the hardcoded limit is because the transaction fails due to ethers estimating too low (example txs 1, 2).
You can however specify your own gas limit or let ethers estimate it for you. Example:
const { Hop } = require('@hop-protocol/sdk')
const ethers = require('ethers')
require('dotenv').config()
async function main() {
const hop = new Hop('mainnet')
const privateKey = process.env.PRIVATE_KEY
const provider = new ethers.providers.getDefaultProvider('mainnet')
const signer = new ethers.Wallet(privateKey, provider)
const bridge = hop.connect(signer).bridge('ETH')
const txData = await bridge.populateSendTx(ethers.utils.parseUnits('0.01', 18), 'ethereum', 'optimism')
// txData.gasLimit = 150_000 // your own custom gas limit
delete txData.gasLimit // let ethers estimate gas limit
console.log(txData)
const tx = await signer.sendTransaction(txData)
console.log(tx)
}
main().catch(console.error)
We're planning on removing the hardcoded value once the rpc providers return a more reliable gas limit for Optimism and Base, since currently it fails with estimated gas limit and users aren't able to perform transfers.
from hop.
I see, thank you for the response--will give this a whirl. Previously we had modified the code to use the gas estimation from populateSendTx
but were running into the underestimate of gas limit like you mentioned, interesting that the underlying issue is ethers.
500000 though was too high for us because we were trying to do a full sweep of max
native ether, anecdotally 170000 seems to be a more reasonable hardcoded limit at least for OP
from hop.
Even when using the above approach, sending the transaction always fails with:
Error: insufficient funds for intrinsic transaction cost [ See: https://links.ethers.org/v5-errors-INSUFFICIENT_FUNDS ] (error={"rawMessage":"Error forwarded from node: insufficient funds for gas * price + value: balance 3390584819344368, tx cost 8351900601944368, overshot 4961315782600000","code":-32603,"message":"Magic RPC Error: [-32603] Error forwarded from node: insufficient funds for gas * price + value: balance 3390584819344368, tx cost 8351900601944368, overshot 4961315782600000"}, method="sendTransaction", transaction=undefined, code=INSUFFICIENT_FUNDS, version=providers/5.7.0)
When trying to do a full sweep... it seems something about the bridge transaction causes ethers to overestimate the txn cost and return early (before even submitting to the network where it would presumably fail)
from hop.
Actually, once we also specified other gas parameters such as maxFeePerGas
and maxPriorityFeePerGas
which aligned with our gas estimation it started working.
The issue seemed to be with gas spiking as the txn was submitted.
from hop.
Thanks for the support!
from hop.
Related Issues (20)
- Type issues in version 0.0.1-beta.314 HOT 2
- Unstoppable Domains Login integration request
- Error: rpcUrl could not be found for network: arbitrum HOT 1
- replace lerna and netlify with pnpm and vercel. HOT 1
- mirgate frontend framework from react to nextjs. HOT 5
- Type issue in all versions since `0.0.1-beta.316` HOT 5
- `yarn` or `npm`? HOT 3
- Hop tokens HOT 2
- pr
- PR
- Send Token UI : the form should support deeplinking all URL params for a better UX HOT 1
- 😌
- __Originally posted by @Josnapkb in https://github.com/awesome-selfhosted/awesome-selfhosted/issues/3329__
- Hh
- Yep
- Wrong token symbol HOT 4
- getSendData triggers same rpc call twice HOT 2
- unable to getAmm data HOT 1
- Process Undefined in hop-protocol/sdk HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hop.