连接到 Brownie/Rinkeby 时出现问题
Problems connecting to Brownie/Rinkeby
我对这个编程还很陌生,可能需要更多练习,但我在尝试连接到 Rinkeby 测试网时遇到了问题,似乎看不出问题所在(Windows 10,Powershell ) 不确定它是否是 .env 或我如何设置它们,但我会发送代码或使用屏幕截图创建的相应文件,以查看是否有人可以阐明问题。复制粘贴代码和环境变量的一些屏幕截图。非常感激您的帮忙。出于某种原因,.env 中的导出命令似乎没有执行(第三个附件)。
谢谢
错误:
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()
这是 .env 文件:
export WEB3_INFURA_PROJECT_ID=xxx
export PRIVATE_KEY=xxxx
布朗尼-config.yaml 文件:
dotenv: .env
wallets:
from_key: ${PRIVATE_KEY}
Enviroment variable
Environment variable
.env file export
config
从根目录中的 brownie-config.yaml 文件读取。确保文件的位置在根目录中,并且它的名称在项目中是正确的。
我对这个编程还很陌生,可能需要更多练习,但我在尝试连接到 Rinkeby 测试网时遇到了问题,似乎看不出问题所在(Windows 10,Powershell ) 不确定它是否是 .env 或我如何设置它们,但我会发送代码或使用屏幕截图创建的相应文件,以查看是否有人可以阐明问题。复制粘贴代码和环境变量的一些屏幕截图。非常感激您的帮忙。出于某种原因,.env 中的导出命令似乎没有执行(第三个附件)。
谢谢
错误:
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()
这是 .env 文件:
export WEB3_INFURA_PROJECT_ID=xxx
export PRIVATE_KEY=xxxx
布朗尼-config.yaml 文件:
dotenv: .env
wallets:
from_key: ${PRIVATE_KEY}
Enviroment variable
Environment variable
.env file export
config
从根目录中的 brownie-config.yaml 文件读取。确保文件的位置在根目录中,并且它的名称在项目中是正确的。