I am new to blockchain and I am following the tutorial by Patrick based on the project

I have my code here at :https://github.com/shashankvivek/blockchain/tree/main/smartLottery_contract_revisited

whenever I run my project using deploy script, I am getting

Funded link to contract
  LinkToken.transfer confirmed   Block: 31016770   Gas used: 52458 (90.91%)

  File "C:\Users\snitw\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\_cli\run.py", line 51, in main
    return_value, frame = run(
  File "C:\Users\snitw\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\scripts.py", line 103, in run
    return_value = f_locals[method_name](*args, **kwargs)
  File ".\scripts\deploy_lottery.py", line 52, in main
  File ".\scripts\deploy_lottery.py", line 43, in end_lottery
    end_tx = lottery.endLottery({"from": account})
  File "C:\Users\snitw\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py", line 1710, in __call__
    return self.transact(*args)
  File "C:\Users\snitw\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py", line 1583, in transact
    return tx["from"].transfer(
  File "C:\Users\snitw\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\account.py", line 644, in transfer
    receipt, exc = self._make_transaction(
  File "C:\Users\snitw\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\account.py", line 727, in _make_transaction
    raise VirtualMachineError(e) from None
  File "C:\Users\snitw\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\exceptions.py", line 93, 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.

It seems like a gas issue when I look at the error , and specifically on below line:

end_tx = lottery.endLottery({"from": account})

but I have enough ETH and Gas

enter image description here

Took my keys from https://docs.chain.link/docs/vrf-contracts/v1/ , running solidity 0.6.6

I am running

brownie run .\scripts\deploy_lottery.py --network kovan

1 Answer 1


I also had this issue when my contract itself didn't have any 'Link' token.

I'm also doing the tutorial and looking at your code, I believe the issue is in the fund_with_link line (line 41 of deploy_lottery.py). It should be

tx = fund_with_link(lottery.address)

instead of

tx = fund_with_link(lottery)

You need to fund the 'address' of the contract lottery - as it appears in the repo https://github.com/PatrickAlphaC/smartcontract-lottery/blob/main/scripts/helpful_scripts.py

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.