我正在关注 FreeCodeCamp 的 Solidity 教程,但在尝试使用brownie和infura部署到mainnet-fork时出现错误。如果我部署到 Kovan,一切正常。这是主网分叉不起作用。
我已经设置了.env:
export PRIVATE_KEY = 0xsomethingsomething
export WEB3_INFURA_PROJECT_ID = 2bsomethingsomething
export ETHERSCAN_TOKEN = QBsometoken
和 brownie-config.yaml 包括
dependencies:
- aave/protocol-v2@1.0.1
compiler:
solc:
remappings:
- '@aave=aave/protocol-v2@1.0.1'
dotenv: .env
networks:
default: mainnet-fork
mainnet-fork:
weth_token: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
lending_pool_addresses_provider: '0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5'
dai_eth_price_feed: '0x773616E4d11A78F511299002da57A0a94577F1f4'
dai_token: '0x6b175474e89094c44da98b954eedeac495271d0f'
wallets:
from_key: ${PRIVATE_KEY}
执行时
brownie console --network mainnet-fork
我得到以下输出:
Brownie v1.17.1 - Python development framework for Ethereum
AaveBrowniePyFreecodeProject is the active project.
File "brownie/_cli/__main__.py", line 64, in main
importlib.import_module(f"brownie._cli.{cmd}").main()
File "brownie/_cli/console.py", line 58, in main
network.connect(CONFIG.argv["network"])
File "brownie/network/main.py", line 31, in connect
active = CONFIG.set_active_network(network)
File "brownie/_config.py", line 76, in set_active_network
network = self.networks[id_].copy()
KeyError: 'mainnet-fork'