3

I followed the answer to a similar question posted on here by adding dotenv: .env to the top of my brownie-config.yaml file but still having the same issue.

This is my code in the brownie-config.yaml file:

dotenv: .env

wallets:
  from_key: ${PRIVATE_KEY}

This is the code from my deploy.py code:

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)
    updated_stored_value = simple_storage.retrieve()
    print(updated_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()

This is my terminal output:

BrownieSimpleStorageProject is the active project.

Running 'scripts/deploy.py::main'...
  File "brownie/_cli/run.py", line 50, 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 4, in deploy_simple_storage
    account = get_account()
  File "./scripts/deploy.py", line 18, in get_account
    return accounts.add(config["wallets"]["from_key"])
KeyError: 'wallets'

Any ideas on how to solve this?

Tree:enter image description here

3
  • What's your tree look like? Perhaps your folders are in the wrong place. Commented Nov 5, 2021 at 0:36
  • Added a screenshot of my tree to the post.
    – Basho
    Commented Nov 5, 2021 at 7:47
  • Problem solved!
    – Basho
    Commented Nov 5, 2021 at 19:38

1 Answer 1

2

Your brownie-config.yaml is in the wrong folder. Move it down to the root folder.

In this example, move it from tests to brownie_simple_storage

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.