I am learning Solidity at the moment and I am facing an error when trying to use MockV3Aggregator:
ImportError: cannot import name 'MockV3Aggregator' from 'brownie'
Here is my bronwie-config.yaml:
dependencies:
- smartcontractkit/chainlink-brownie-contracts@1.1.1
- OpenZeppelin/openzeppelin-contracts@3.4.0
compiler:
solc:
remappings:
- "@chainlink=smartcontractkit/chainlink-brownie-contracts@1.1.1"
- "@openzeppelin=OpenZeppelin/openzeppelin-contracts@3.4.0"
networks:
default: development
development:
keyhash: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc"
fee: 100000000000000000
mainnet-fork:
eth_usd_price_feed: "0x5f4ec3df9cbd43714fe2740f5e3616155c5b8419"
rinkeby:
vrf_coordinator: "0x6168499c0cFfCaCD319c818142124B7A15E857ab"
eth_usd_price_feed: "0x8A753747A1Fa494EC906cE90E9f37563A8AF630e"
link_token: "0x01BE23585060835E02B77ef475b0Cc51aA1e0709"
keyhash: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc"
fee: 100000000000000000
verify:
wallets:
from_key: ${PRIVATE_KEY}
And here is where I am trying to access the MockV3Aggregator:
from brownie import (
Contract,
network,
config,
accounts,
MockV3Aggregator,
VRFCoordinatorMock,
LinkToken,
)
FORKED_LOCAL_ENVIRONMENTS = ["mainnet-fork"]
LOCAL_BLOCKCHAIN_ENVIRONMENTS = ["development", "ganache-local"]
DECIMALS = 8
STARTING_PRICE = 200000000000
def get_accounts(index=None, id=None):
if index:
return accounts[index]
if id:
return accounts.load(id)
if (
network.show_active() in LOCAL_BLOCKCHAIN_ENVIRONMENTS
or network.show_active() in FORKED_LOCAL_ENVIRONMENTS
):
return accounts[0]
return accounts.add(config["wallets"]["from_key"])
contract_to_mock = {
"eth_usd_price_feed": MockV3Aggregator,
"v3_aggregator": VRFCoordinatorMock,
"link_token": LinkToken,
}
def get_contract(contract_name):
"""
This function will grab the contract addresses from the brownie
config if defined, otherwise it will deploy a mock version of
that contract and return that mock contract.
Args:
contract_name (string)
Returns:
brownie.network.contract.projectContract: The most recently
deployed version of this contract.
MockV3Aggregator[-1]
"""
contract_type = contract_to_mock[contract_name]
if network.show_active() in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
if len(contract_type <= 0):
deploy_mocks()
contract = contract_type[-1]
else:
contract_address = config["networks"][network.show_active()][contract_name]
# address
# ABI
contract = Contract.from_abi(
contract_type._name, contract_address, contract_type.abi
)
return contract
def deploy_mocks():
account = get_accounts()
MockV3Aggregator.deploy(DECIMALS, STARTING_PRICE, {"from": account})
link_token = LinkToken.deploy({"from": account})
VRFCoordinatorMock.deploy(link_token.address, {"from": account})
print("Mocks deployed...")
Any help would be appreciated thanks