Simulating transactions on Ganache v7 fork throws insufficient funds error
See original GitHub issuehey there, appreciate your work on this amazing tool! when trying to integrate the latest version (ganache 7.0.0) into my previously working code (which used ganache-core 2.13.2) I am seeing some non-deterministic behaviour. Sometimes when simulating a transaction on a fork it will throw an insufficient funds for intrinsic transaction cost
error. But other times, running the exact same code will work as expected. Here is what I am doing:
const provider = new ethers.providers.Web3Provider(ganache.provider({
fork: {
url: MY_INFURA_URL,
blockNumber: SOME_BLOCK_NUMBER
},
wallet: {
unlockedAccounts: [USER_ADDRESS]
}
}) as any)
const tetherContract = new ethers.Contract(TETHER_ADDRESS, TETHER_ABI, provider.getSigner(USER_ADDRESS))
const userTetherBalance = await tetherContract.balanceOf(USER_ADDRESS)
const tx = await tetherContract.transfer(USER2_ADDRESS, userTetherBalance) //<---- throws error here
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
insufficient funds for intrinsic transaction cost
I have been trying to deploy an NFT contract through my terminal. However, it keeps giving me the error message: reason: 'insufficient funds...
Read more >Is there a way to solve this insufficient funds for gas when ...
This should be an issue with insufficient account balance. Try sending the same transaction using an high-level function like transact() to ...
Read more >ConsenSys/truffle - Gitter
Hi, While running truffle unbox react, it works fine till "cleaning up temporary files", but shows error as "Unbox failed" for "setting up...
Read more >Mastering Blockchain, Second Edition
A hard fork was required on the Ethereum blockchain to reverse the impact of the hack and initiate the recovery of the funds....
Read more >Mastering Ethereum
ETH, you want to send 1 ETH, so why is MetaMask saying you have insufficient funds? The answer is because of the cost...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Appreciate the explanation! However, since this code will be client-facing I wouldn’t want to use this workaround (and possibly link to this issue in a comment to explain why I’m setting
maxFeePerGas
). As such, I will hold off on integrating Ganache v7 and stick toganache-core
for the time being until a longer-term fix is implemented. Ideally, since users did not have to set this parameter before, they shouldn’t have to set it in the latest version eitherHi @haseebrabbani, we did some looking into this and think there’s a combination of factors contributing to the issue. If you change your
transfer
call to include amaxFeePerGas
, as follows:all of the transfers work. Whenever you fork from a block, the new “latest” block is used to set the
baseFeePerGas
of the next block. When no gas information is specified on a transaction, the default base fee is set by Ganache. This is an expensive gas premium because it ensures it will make it onto the block - but you’re overspending on gas in that case. So, this was leading to insufficient funds to perform the transfer.We plan to improve upon this in a number of ways:
eth_feeHistory
RPC method to help set those parameters (#1470)baseFeePerGas
#1573@haseebrabbani Let me know if the above fix doesn’t work for you and we can investigate further. If it does work, feel free to close this issue!