I'm pretty new to this programming and maybe need more practice but I've been having problems trying to connect to the Rinkeby testnet and can't seem to see the problem (Windows 10, Powershell) not sure if it's the .env or how I set them up but I'll send the code or the respective files created with screenshots to see I someone could illuminate the problem. Copy pasted the code and some screenshots of the environment variables. Your help is very much appreciated. For some reason the export commands in the .env are seems as they are not executing(Third attachment).
Thank you
Error:
Brownie v1.18.1 - Python development framework for Ethereum
BrownieSimpleStorageProject is the active project.
Running 'scripts\deploy.py::main'...
File "C:\Users\jorge\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\brownie\_cli\run.py", line 51, in main
return_value, frame = run(
File "C:\Users\jorge\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\brownie\project\scripts.py", line 103, in run
return_value = f_locals[method_name](*args, **kwargs)
File ".\scripts\deploy.py", line 25, in main
deploy_simple_storage()
File ".\scripts\deploy.py", line 5, in deploy_simple_storage
account = get_account()
File ".\scripts\deploy.py", line 21, in get_account
return accounts.add(config["wallets"]["from_key"])
KeyError: 'wallets'
deploy.py:
from brownie import accounts, config, SimpleStorage, network
def deploy_simple_storage():
account = get_account()
simple_storage = SimpleStorage.deploy({"from": account})
# Transaction
# Call
stored_value = simple_storage.retrieve()
print(stored_value)
transaction = simple_storage.store(15, {"from": account})
transaction.wait(1)
updated_value = simple_storage.retrieve()
print(updated_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()
Here's the .env file:
export WEB3_INFURA_PROJECT_ID=xxx
export PRIVATE_KEY=xxxx
brownie-config.yaml file:
dotenv: .env
wallets:
from_key: ${PRIVATE_KEY}
CodePudding user response:
config
reads from brownie-config.yaml file which is in the root directory. make sure the location of the file is in root and its name is correct in the project.