Wallets

KeyError:‘錢包’

  • May 6, 2021

目錄截圖:

目錄

這是我的 brownie.config.yaml 文件中的程式碼:

reports:
 exclude_contracts:
   - SafeMath
dependencies:
 - smartcontractkit/chainlink-brownie-contracts@1.0.2
 - OpenZeppelin/openzeppelin-contracts@3.4.0
compiler:
 solc:
   remappings:
     - '@chainlink=smartcontractkit/chainlink-brownie-contracts@1.0.2'
     - '@openzeppelin=OpenZeppelin/openzeppelin-contracts@3.4.0'
wallets:
 from_key: ${PRIVATE_KEY}
 from_mnemonic: ${MNEMONIC} 

deploy_advanced.py 中的程式碼:

from brownie import AdvancedCollectible, accounts, network, config

def main():
   dev = accounts.add(config['wallets']['from_key'])
   print(dev)

當我嘗試執行“brownie run scripts/advanced_collectible/deploy_advanced.py”時,出現以下錯誤:

Running 'scripts/advanced_collectible/deploy_advanced.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/advanced_collectible/deploy_advanced.py", line 4, in main
   dev = accounts.add(config['wallets']['from_key'])
KeyError: 'wallets'

有關如何解決此錯誤的任何建議?

更改 brownie.config.yaml -> brownie-config.yaml

引用自:https://ethereum.stackexchange.com/questions/98320