Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Quickstart Kovan] ValueError: Gas estimation failed: 'The execution failed due to an exception.' #15

Open
Rlfm opened this issue Aug 4, 2021 · 34 comments

Comments

@Rlfm
Copy link

Rlfm commented Aug 4, 2021

Hi, while following the steps to test the repo on the Kovan test network I ran into this issue : **. get_weth.py works well, I can see the ETH being replaced by WETH on Metamask, deployement_v2 works fine too (the contract is visible on etherscan). The issue resides in run_flash_loan_v2.py at line 20 : tx = flashloan.flashloan(weth, {"from": acct}). Could you help me out. Thx in advance

** : brownie run scripts/run_flash_loan_v2.py --network kovan
Brownie v1.15.2 - Python development framework for Ethereum

AaveFlashloanMixProject is the active project.

Running 'scripts/run_flash_loan_v2.py::main'...
Getting Flashloan contract...
Funding Flashloan contract with WETH...
Transaction sent: 0x1e9e940aacbbf711e8e406078c17b2bf7a6a787828ef85f596e6007dcd4a6241
Gas price: 1.1 gwei Gas limit: 56934 Nonce: 150
WethInterface.transfer confirmed - Block: 26576860 Gas used: 51759 (90.91%)

Executing Flashloan...
File "brownie/_cli/run.py", line 49, in main
return_value, frame = run(
File "brownie/project/scripts.py", line 103, in run
return_value = f_locals[method_name](*args, **kwargs)
File "./scripts/run_flash_loan_v2.py", line 20, in main
tx = flashloan.flashloan(weth, {"from": acct})
File "brownie/network/contract.py", line 1338, in call
return fn(*args) # type: ignore
File "brownie/network/contract.py", line 1691, in call
return self.transact(*args)
File "brownie/network/contract.py", line 1565, in transact
return tx["from"].transfer(
File "brownie/network/account.py", line 658, in transfer
gas_limit = Wei(gas_limit) or self._gas_limit(to, amount, gas_price, gas_buffer, data)
File "brownie/network/account.py", line 425, in _gas_limit
gas_limit = self.estimate_gas(to, amount, gas_price, data or "")
File "brownie/network/account.py", line 618, in estimate_gas
raise ValueError(
ValueError: Gas estimation failed: 'The execution failed due to an exception.'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.

@cryptololo
Copy link

What would be the best program for a beginner to learn how to code flash loans? Start with HTML, Java and Python?

@spaceh3ad
Copy link

Got same problem.

josh@pc ~/Code/Blockchain_Dev/Brownie/aave-flashloan-mix (master) $ brownie run scripts/run_flash_loan_v2.py --network kovan
Brownie v1.17.0 - Python development framework for Ethereum

AaveFlashloanMixProject is the active project.

Running 'scripts/run_flash_loan_v2.py::main'...
Getting Flashloan contract...
Funding Flashloan contract with WETH...
Transaction sent: 0x7d08fa06666dc8a9149422caadd794e156328a8e3e53eb5e926450061cc7d198
  Gas price: 1.1 gwei   Gas limit: 56934   Nonce: 10
  WethInterface.transfer confirmed   Block: 27947784   Gas used: 46959 (82.48%)

Executing Flashloan...
  File "brownie/_cli/run.py", line 50, in main
    return_value, frame = run(
  File "brownie/project/scripts.py", line 103, in run
    return_value = f_locals[method_name](*args, **kwargs)
  File "./scripts/run_flash_loan_v2.py", line 20, in main
    tx = flashloan.flashloan(weth, {"from": acct})
  File "brownie/network/contract.py", line 1260, in __call__
    return fn(*args)  # type: ignore
  File "brownie/network/contract.py", line 1622, in __call__
    return self.transact(*args)
  File "brownie/network/contract.py", line 1495, in transact
    return tx["from"].transfer(
  File "brownie/network/account.py", line 642, in transfer
    receipt, exc = self._make_transaction(
  File "brownie/network/account.py", line 725, in _make_transaction
    raise VirtualMachineError(e) from None
  File "brownie/exceptions.py", line 121, in __init__
    raise ValueError(str(exc)) from None
ValueError: Gas estimation failed: 'The execution failed due to an exception.'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.

@jasonbohne123
Copy link

I get the same error as well

ValueError: Gas estimation failed: 'The execution failed due to an exception.'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.

@toddabraham
Copy link

I'm getting the same error. Has anyone manage to resolve or?

@amazzuca
Copy link

make sure you have weth in your account. Probably running the get_weth.py

@teryanarmen
Copy link

I had this same problem. For me it was due to a low balance of ETH/wETH. I changed the MINIMUM_FLASHLOAN_WETH_BALANCE to 0.1 instead of 1 and also the get_weth function i did .1 weth instead of .1eth. Got eth from here: https://faucet.paradigm.xyz/

@oguzpeker
Copy link

I have the same problem, and in my wallet I have enough ETH and WETH. I can't find a solution.

@amazzuca
Copy link

amazzuca commented Jan 3, 2022

I had this same problem. For me it was due to a low balance of ETH/wETH. I changed the MINIMUM_FLASHLOAN_WETH_BALANCE to 0.1 instead of 1 and also the get_weth function i did .1 weth instead of .1eth. Got eth from here: https://faucet.paradigm.xyz/

Where did you change the MINIMUM_FLASHLOAN_WETH_BALANCE setting?

@teryanarmen
Copy link

I had this same problem. For me it was due to a low balance of ETH/wETH. I changed the MINIMUM_FLASHLOAN_WETH_BALANCE to 0.1 instead of 1 and also the get_weth function i did .1 weth instead of .1eth. Got eth from here: https://faucet.paradigm.xyz/

Where did you change the MINIMUM_FLASHLOAN_WETH_BALANCE setting?

In /scripts/run_flash_loan_v2.py

@dhruvja
Copy link

dhruvja commented Jan 12, 2022

even i am getting this error
Gas estimation failed: 'The execution failed due to an exception.'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.
Even though i have sufficient funds in both Eth and Weth.
Im able to deposit, but not able to borrow.

@topeklc
Copy link

topeklc commented Jan 17, 2022

Same here

@highfrog
Copy link

Same issue here. Have sufficient funds in both eth and weth yet still get gas estimation failed.

@omartin2010
Copy link

no one ever got this resolved? I've got 2 eth and 1 weth in my test account and have funded 1 weth to the contract. No cigar. Anyone?

@A01138704
Copy link

A01138704 commented Feb 3, 2022

i did manage to execute properly the contract with less than 2ETH on my kovan account and only had to extract one 0 of the lending amount leaving me with a 0.1 WETH loan... [https://kovan.etherscan.io/tx/0x58d527dc367e768bad912fd5a576ced1d8bc6ff88fb6463b0ec9d9acc35cb9bc ]
edit: No logic was implemented in the contract so I had to pay the loan premium fee by only getting the flash loan and giving back the loan.

this dosent solve anything but adjusting this parameters made me understand a little bit more where is the problem, in addition I ran the brownie test but didn't work.

@cftmonGIT
Copy link

i had the same exact issue , i had enough eth/weth in my wallet , and weth in the Smart contract.
Changed all my variables to deposit 0.1 ETH instead. Not sure how to debug this

@berkaybulut
Copy link

I had this same issue. I had it resolved using an approval signature on my account. Try:
weth.approve(acct, '1 ether', {'from':acct})
You can replace 1 ether with any amount using integer values.

@basusus
Copy link

basusus commented Feb 7, 2022

Did you put : weth.approve(acct, '1 ether', {'from':acct})
in weth_get.py?

@berkaybulut
Copy link

I worked on brownie console line by line - but it should also work in that file. Just make sure that you have signed the contract.

@cmedinasoriano
Copy link

Is there a specific reason why it has to be approved? I honestly thought that by approving the Lending pool that was enough, I would have never guessed I had to approve myself to spend my own eth or am I misunderstanding how it works.

@MichiTheBlock
Copy link

MINIMUM_FLASHLOAN_WETH_BALANCE

I had the same problem. just head over to the file run_flash_loan_v2.py

change the code to
line3:
MINIMUM_FLASHLOAN_WETH_BALANCE = 100000000000000000

line18:
weth.transfer(flashloan, 1000000000000000000, {"from": acct})

then it should work. at least it did on my side.

To be honest there are a few problems one can encounter with this example, which is quite good because you have to put more effort in this. on windows the source commands dont work, on my side the cahnge in the PRIVATE_KEY with 0x... did not work because of an non hex issue response->pasted the private_key in the brownie-config.yaml itself.

but now it went through. Hope you guys can make it.

@jerrychan807
Copy link

jerrychan807 commented Feb 21, 2022

The following setting in brownie-config.yaml worked for me:

settings:
  gas_limit: "2074044"

@ch1ch0gz
Copy link

The following setting in brownie-config.yaml worked for me:

settings:
  gas_limit: "2074044"

This worked for me...what is the reason for that specific gas limit?

@maghatashi
Copy link

maghatashi commented Mar 16, 2022

In what line did you put the "settings"? Adding that line definitely did not work for me. Maybe it is just better to test the contract on Ropsten with V1 since it is easier to get a larger amount or eth there? I tried changing the wei and ether amounts in the contracts as well and could only get as far as the last (and most important) step which throws this same "ValueError." Any other suggestions would be appreciated. Thanks for the responses. If I find a proper solution I´ll post.

@ch1ch0gz
Copy link

You can add the gas in the transaction on run_flash_loan.py
tx = flashloan.flashloan(weth, {"from": acct, "gas_limit": 2074044})

@maghatashi
Copy link

That sounds about right. Thanks so much. It helped but then I got a VM revert error, so I researched and had to add some more code to that. The result:
tx = flashloan.flashloan(weth, {"from": acct, "gas_limit": 2074044, 'allow_revert': True})
That solved the VM issue and no more Gas Error either.

@fowardelcac
Copy link

Hi! i've a problem, i used this: tx = flashloan.flashloan(weth, {"from": acct, "gas_limit": 2074044, 'allow_revert': True}) but returns this: RPCRequestError: Accessing TransactionReceipt.revert_msg on a reverted transaction requires the debug_traceTransaction RPC endpoint, but the node client does not support it or has not made it available.
whats this?

@khaloosaman
Copy link

khaloosaman commented Apr 24, 2022

Hi! i've a problem, i used this: tx = flashloan.flashloan(weth, {"from": acct, "gas_limit": 2074044, 'allow_revert': True}) but returns this: RPCRequestError: Accessing TransactionReceipt.revert_msg on a reverted transaction requires the debug_traceTransaction RPC endpoint, but the node client does not support it or has not made it available. whats this?

Hi, did you find any solution for this problem? it seems like the problem is from the node providers side but i dont know how to handle it, Iam not working on aave-flashloan but iam getting the same error in my tx, i think they might have the same solution.

@wwignes88
Copy link

wwignes88 commented Apr 26, 2022

I ran into this error @ 9:45:43 in the video. Finally what resolved it was going back to 9:01:06 in the video where the get_weth.py script was ran directly. You should have 0.1 wETH after this step. Make sure you run it on kovan though (I suspect this might be the issue for some people). Once the dust settled - after much double checking every line - I think thats all I changed. Runs fine now - on Kovan anyway.

Note however that it remains an issue for me on mainnet when forking throgh alchemy instead of infura for the node provider that I get the error "Able to launch RPC client, but unable to connect." When I fork through infura my code runs fine on mainnet and kovan. See the video @ 5:59:40 and 6:28:40 for how to configure a network which forks form a different node provider.

@fowardelcac
Copy link

Hi! i've a problem, i used this: tx = flashloan.flashloan(weth, {"from": acct, "gas_limit": 2074044, 'allow_revert': True}) but returns this: RPCRequestError: Accessing TransactionReceipt.revert_msg on a reverted transaction requires the debug_traceTransaction RPC endpoint, but the node client does not support it or has not made it available. whats this?

Hi, did you find any solution for this problem? it seems like the problem is from the node providers side but i dont know how to handle it, Iam not working on aave-flashloan but iam getting the same error in my tx, i think they might have the same solution.

Hi i didnt find a solution for this, im sure that im using right network and the contract has weth, but i'll check it again.

@lucaregner
Copy link

Hi! i've a problem, i used this: tx = flashloan.flashloan(weth, {"from": acct, "gas_limit": 2074044, 'allow_revert': True}) but returns this: RPCRequestError: Accessing TransactionReceipt.revert_msg on a reverted transaction requires the debug_traceTransaction RPC endpoint, but the node client does not support it or has not made it available.
whats this?

Hello there, I am encountering the same error and cannot find a way to work around this error. Was anyone able to solve this problem and give a short explanation? Thank you in advance!

@harshanas
Copy link

harshanas commented Jun 13, 2022

I did three things and got it successfully working:

  1. Change the amount get_weth.py file to a lower amount:
tx = weth.deposit({"from": acct, "value": 10000000000000000})
  1. Change the amounts in the run_flash_loan_v2.py file
    Line 3:
MINIMUM_FLASHLOAN_WETH_BALANCE = 20000000000000

Line 19:

weth.transfer(flashloan, 20000000, {"from": acct})
  1. Change the hardcoded flash loan amount in FlashloanV2.sol
    Line 104:
uint256 amount = 20000000;

PS: I had around 0.1 Test Ether in my account when I was able to run this.

@Abdel364
Copy link

i have run the flashloan contract for the first time it went well but the second time it gives me this error Gas estimation failed: 'execution reverted'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.
and i do have testnet eth and everything
can someone help me please

@Abdel364
Copy link

please which video are you talking about

@wwignes88
Copy link

please which video are you talking about

Patrick Collins video

Apologies I presumed that video was what brought people to this thread. I also updated my comment with a link to the video.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests