I'm following the course Solidity, Blockchain, and Smart Contract Course and I cannot pass the test_can_end_lottery test in the development network, I didn't test the other networks.
It looks like I can successfully fund with LINK the lottery contract but the transaction endLottery reverts. I checked all the amounts and fees twice to be sure they have 17 zeros.
I pasted below the error, the config, and the function end_lottery().
Error:
LINK funded to contract
LinkToken.transfer confirmed Block: 7 Gas used: 51398 (0.43%)
Transaction sent: 0xe97361a7db515a30e3feac79b1e14d6e16abd3132949b17a82fbb83cd87bc619
Gas price: 0.0 gwei Gas limit: 12000000 Nonce: 7
Lottery.endLottery confirmed (reverted) Block: 8 Gas used: 11813268 (98.44%)
File "brownie/_cli/run.py", line 51, 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/deploy_lottery.py", line 90, in main
end_lottery()
File "./scripts/deploy_lottery.py", line 71, in end_lottery
tx = lottery.endLottery({"from": account})
File "brownie/network/contract.py", line 1710, in __call__
return self.transact(*args)
File "brownie/network/contract.py", line 1583, in transact
return tx["from"].transfer(
File "brownie/network/account.py", line 682, in transfer
receipt._raise_if_reverted(exc)
File "brownie/network/transaction.py", line 446, in _raise_if_reverted
raise exc._with_attr(
VirtualMachineError: revert
def end_lottery():
account = get_account()
lottery = Lottery[-1]
# to request randomness i need to fund LINK token to the contract/VRFCoordinator so
# 1. I need LINK token in the account
tx = fund_with_link(lottery)
tx.wait(1)
# 2. end the lottery
tx = lottery.endLottery({"from": account})
tx.wait(1)
# wait for the chainlink contract to send the random winner
time.sleep(60)
print(f"{lottery.recentWinner()} is the new winner")
return
I am getting very confused, any idea why this may be happening?
Thanks a lot
Hi,
I'm following the course Solidity, Blockchain, and Smart Contract Course and I cannot pass the test_can_end_lottery test in the development network, I didn't test the other networks.
It looks like I can successfully fund with LINK the lottery contract but the transaction endLottery reverts. I checked all the amounts and fees twice to be sure they have 17 zeros. I pasted below the error, the config, and the function end_lottery().
Error:
the brownie-config file includes:
and the function end_lottery()
I am getting very confused, any idea why this may be happening? Thanks a lot