-
|
Hello, I am having an error under Lesson 7. The thing is that I can import MockV3Aggregator but I can not import VRFCoordinatorMock or LinkToken. One thing that I have noted is that if I switch the order under the "from brownie import", putting LInkToken before the VRFCoordinatorMock is that one that trougth the error. This image is for you to show the .json structure and the folder structure. This is Helpful Scripts code: from brownie import (
network,
accounts,
config,
Contract,
MockV3Aggregator,
VRFCoordinatorMock,
LinkToken,
)
FORKED_LOCAL_ENVIROMENTS = ["mainnet-fork", "mainnet-fork-dev"]
LOCAL_BLOCKCHAIN_ENVIROMENTES = ["development", "ganache-local"]
def get_account(index=None, id=None):
if index:
return accounts[index]
if id:
return accounts.load[id]
if (
network.show_active() in LOCAL_BLOCKCHAIN_ENVIROMENTES
or network.show_active() in FORKED_LOCAL_ENVIROMENTS
):
return accounts[0]
return accounts.add(config["wallets"]["from_key"])
contract_to_mock = {
"eth_usd_price_feed": MockV3Aggregator,
"vrf_coordinator": VRFCoordinatorMock,
"link_token": LinkToken,
}
def get_contract(contract_name):
"""This function will grab the contract addresses from the brownie config
if defined, otherwhise, it will deploy a mock version of that contract, and
return the mock contract.
Arg:
contract_name (string)
Returns:
brownie.network.contract.ProjectContracts: The most recently deployed
version of this contract
"""
contract_type = contract_to_mock[contract_name]
if network.show_active() in LOCAL_BLOCKCHAIN_ENVIROMENTES:
if len(contract_type) <= 0:
deploy_mocks()
contract = contract_type[-1]
else:
contract_address = config["networks"][network.show_active()][contract_name]
contract = Contract.from_abi(
contract_type._name, contract_address, contract_type.abi
)
return contract
DECIMALS = 8
STARTING_PRICE = 2000000000
def deploy_mocks(decimals=DECIMALS, initial_value=STARTING_PRICE):
account = get_account()
MockV3Aggregator.deploy(decimals, initial_value, {"from": account})
link_token = LinkToken.deploy({"from": account})
VRFCoordinatorMock.deploy(link_token.address, {"from": account})
print("Mocks Deployed")This one is deploy_lottery script: from scripts.helpful_scripts import get_account, get_contract
from brownie import Lottery, network, config
def deploy_lottery():
account = get_account(id="myaccount")
lottery = Lottery.deploy(
get_contract("eth_usd_price_feed").address,
get_contract("vrf_coordinator").address,
get_contract("link_token").address,
config["networks"][network.show_active()]["fee"],
config["networks"][network.show_active()]["keyhash"],
{"from": account},
publish_source=config["networks"][network.show_activeU()].get("verify", False),
)
print("lottery Deplyed!!")
def main():
deploy_lottery()This is the Lottery.sol file. All other mock codes has been copied from the course folder. I tried:
I'll copy also my config.yaml file in case there is something that I'm missing. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
|
please post your .sol code and don't use screenshots use the editors <> button. ... and can you please take a look at this article here, it describes best practices on how to ask good questions so that others can really help you. |
Beta Was this translation helpful? Give feedback.
-
|
Hello @EzeCerino |
Beta Was this translation helpful? Give feedback.
-
|
Just tested it, the file extension must be *.sol to be compiled. Your not compiled files have the wrong file extension starting with a capital S. Please correct this and compile again. |
Beta Was this translation helpful? Give feedback.


Just tested it, the file extension must be *.sol to be compiled. Your not compiled files have the wrong file extension starting with a capital S. Please correct this and compile again.