PatrickAlphaC / brownie_simple_storage

25 stars 32 forks source link

Facing Issue when running brownie run scripts/deploy.py --network rinkeby #1

Closed musamasiddiqui closed 3 years ago

musamasiddiqui commented 3 years ago

Hi, I tried running the following command but facing error:

brownie run scripts/deploy.py --network rinkeby

Following is the error:

BrownieSimpleStorageProject is the active project.

Running 'scripts/deploy.py::main'... 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_localsmethod_name File "./scripts/deploy.py", line 20, in main deploy_simple_storage() File "./scripts/deploy.py", line 5, in deploy_simple_storage simple_storage = SimpleStorage.deploy({"from": account}) File "brownie/network/contract.py", line 600, in call return tx["from"].deploy( AttributeError: 'function' object has no attribute 'deploy'

Here is the screenshot of the above error: https://prnt.sc/1x87zan

Any idea how to fix? Thank you.

PatrickAlphaC commented 3 years ago

Send what your deploy script looks like please.

musamasiddiqui commented 3 years ago

Send what your deploy script looks like please.

Thank you for replying. Highly appreciated. Here is the deploy.py script:

from brownie import accounts, config, SimpleStorage, network

def deploy_simple_storage():
    account = get_account
    simple_storage = SimpleStorage.deploy({"from": account})
    stored_value = simple_storage.retrieve()
    print(stored_value)
    transaction = simple_storage.store(15, {"from": account})
    transaction.wait(1)
    udpated_stored_value = simple_storage.retrieve()
    print(udpated_stored_value)

def get_account():
    if network.show_active() == "development":
        return accounts[0]
    else:
        return accounts.add(config["wallets"]["from_key"])

def main():
    deploy_simple_storage()

EDIT: I just checked my deploy.py with the one you already have on GitHub. I had typed "account = get_account" instead of "account = get_account()". So I updated it.

Now I am getting the following error: Running 'scripts/deploy.py::main'... 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/deploy.py", line 22, in main deploy_simple_storage() File "./scripts/deploy.py", line 6, in deploy_simple_storage simple_storage = SimpleStorage.deploy({"from": account}) File "brownie/network/contract.py", line 600, in call return tx["from"].deploy( File "brownie/network/account.py", line 508, in deploy receipt, exc = self._make_transaction( File "brownie/network/account.py", line 743, in _make_transaction exc = VirtualMachineError(e) File "brownie/exceptions.py", line 85, in init raise ValueError(exc["message"]) from None ValueError: insufficient funds for gas price + value

I guess I don't have enough funds for the transaction. Is this the only reason I am getting the above error or there could be another? Thanks a lot for your time, Patrick. Loving your course.

PatrickAlphaC commented 3 years ago

Yup! You got the first error.

So the second one is saying you don't have enough funds. You need testnet rinkeby ETH in your Private key environment variable!!

https://faucets.chain.link/rinkeby

^^ Use this.

PatrickAlphaC commented 3 years ago

Closing for now, feel free to follow up.

Otherwise, you could do:

brownie run scripts/deploy.py --network development

and you'll see it work!