我對這個編程很陌生,可能需要更多的練習,但我在嘗試連接到 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'
部署.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
brownie-config.yaml 檔案:
dotenv: .env
wallets:
from_key: ${PRIVATE_KEY}
環境變數
環境變數
.env 檔案匯出
uj5u.com熱心網友回復:
config從根目錄中的 brownie-config.yaml 檔案中讀取。確保檔案的位置在根目錄中,并且它的名稱在專案中是正確的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/439096.html
上一篇:在AndroidJetpackcompose中如何實作GestureDetector.SimpleOnGestureListener.....?
