0

我一直在关注 Solidity、区块链和智能合约课程 - 从初学者到专家 Python 教程 ( https://www.youtube.com/watch?v=M576WGiDBdQ&t=28658s )。当我运行 deploy_lottery.py 时,它会在结束抽奖时崩溃。这是 Lottery.sol 中的代码片段

function endLottery() public onlyOwner {
        lottery_state = LOTTERY_STATE.CALCULATING_WINNER;
        bytes32 requestId = requestRandomness(keyhash, fee);

        emit RequestedRandomness(requestId);
    }

这是 deploy_lottery.py 中的代码片段

def end_lottery():
    account = get_account()
    lottery = Lottery[-1]
    # fund the contract
    # then end the lottery

    tx = fund_with_link(lottery.address)
    tx.wait(1)
    print("Here")
    ending_transaction = lottery.endLottery({"from": account})
    print("ended transaction")
    ending_transaction.wait(1)
    time.sleep(180)
    print(f"{lottery.recentWinner()} is the new winner!")

我还附上了错误的快照。提前致谢。 https://i.stack.imgur.com/yU8jC.png

4

1 回答 1

0

我一直遇到同样的错误。解决方案是用足够的代币为合同提供资金。为了测试,我在 fund_with_link() 中做了 amount=5000000000000000000

于 2022-02-14T20:46:22.673 回答