0

I'm following the solidity course on youtube by patrick collins and i'm stuck with an issue i've described below, the deploy_and_create.py script was executed to be deployed to rinkeby network and i'm receiving the error -

ValueError: Gas estimation failed: 'invalid opcode: INVALID'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.

/////

from scripts.helpful_scripts import (
    fund_with_link,
    get_account,
    OPEN_SEA_URL,
    get_contract,
)

from brownie import AdvancedCollectible, network, config


sample_token_uri = (
    "ipfs://Qmd9MCGtdVz2miNumBHDbvj8bigSgTwnr4SbyH6DNnpWdt?filename=0-PUG.json"
)


def deploy_and_create():
    account = get_account()
    advanced_collectible = AdvancedCollectible.deploy(
        get_contract("vrf_coordinator"),
        get_contract("link_token"),
        config["networks"][network.show_active()]["keyhash"],
        config["networks"][network.show_active()]["fee"],
        {"from": account},
    )

    fund_with_link(advanced_collectible.address)

    creating_tx = advanced_collectible.createCollectible({"from": account})
    creating_tx.wait(1)
    print("New token has been created!")
    #     f"Awesome, you can now view your NFT at {OPEN_SEA_URL.format(advanced_collectible.address, advanced_collectible.tokenCounter() - 1)}"
    # )

    # print("Please wait up to 20 minutes, and hit the refresh metadata button.")
    # return advanced_collectible


def main():
    deploy_and_create()

Screenshot of the execution: enter image description here

2 Answers 2

0

Looks like you do not have enough gas. Please change the amount on the fund_with_link function to a lower number like 0.003 as below:

def fund_with_link(contract_address, account=None, link_token=None, amount=Web3.toWei(0.003, "ether")):
0

In your brownie-config.yaml file you can also manually set the gas limit for all transactions in a project to a very high number if you'll be doing transactions with potentially unexpectedly high gas usage.

networks:
  live:
    gas_limit: "1000000"

If you're using a development network, the default is already max, so if you tx fails due to the gas limit being too low, then something else is going wrong with the transaction in the contract you're working with.

You can read more about the brownie config file in the docs: https://eth-brownie.readthedocs.io/en/stable/config.html

Also the section about the gas limit param: https://eth-brownie.readthedocs.io/en/stable/config.html#networks.gas_limit

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.