PatrickAlphaC / nft-demo

37 stars 51 forks source link

cannot import name 'LinkToken' from 'brownie' #7

Closed ariqbailey closed 2 years ago

singhKaramjeet commented 2 years ago

i am having the same error

singhKaramjeet commented 2 years ago

image This is the error and this the deploy and create script of advance collectible. """

`from scripts.helpful_scripts import (
    get_account,
    OPENSEA_URL,
    get_contract,
    fund_with_link,
)
from brownie import AdvancedCollectible, network, config

def deploy_and_create():
    account = get_account()
    # We want to be able to use the deployed contracts if we are on a testnet
    # Otherwise, we want to deploy some mocks and use those
    # Rinkeby
    advanced_collectible = AdvancedCollectible.deploy(
        get_contract("vrf_coordinator"),
        get_contract("link_token"),
        config["networks"][network.show_active()]["keyhash"],
        config["networks"][network.show_active()]["fee"],
        {"from": account},
    )
    # fund_with_link(advanced_collectible.address)
    # creating_tx = advanced_collectible.createCollectible({"from": account})
    # creating_tx.wait(1)
    # print("New token has been created!")
    # return advanced_collectible, creating_tx

def main():
    deploy_and_create()`

""" this is the helpful script """ `from brownie import accounts, network, config, LinkToken, VRFCoordinatorMock, Contract from web3 import Web3

LOCAL_BLOCKCHAIN_ENVIRONMENTS = ["hardhat", "development", "ganache", "mainnet-fork"] OPENSEA_URL = "https://testnets.opensea.io/assets/{}/{}" BREED_MAPPING = {0: "PUG", 1: "SHIBA_INU", 2: "ST_BERNARD"}

def get_breed(breed_number): return BREED_MAPPING[breed_number]

def get_account(index=None, id=None): if index: return accounts[index] if network.show_active() in LOCAL_BLOCKCHAIN_ENVIRONMENTS: return accounts[0] if id: return accounts.load(id) return accounts.add(config["wallets"]["from_key"])

contract_to_mock = {"link_token": LinkToken, "vrf_coordinator": VRFCoordinatorMock}

def get_contract(contract_name): """ This function will either:

def deploy_mocks(): """ Use this script if you want to deploy mocks to a testnet """ print(f"The active network is {network.show_active()}") print("Deploying mocks...") account = get_account() print("Deploying Mock LinkToken...") link_token = LinkToken.deploy({"from": account}) print(f"Link Token deployed to {link_token.address}") print("Deploying Mock VRF Coordinator...") vrf_coordinator = VRFCoordinatorMock.deploy(link_token.address, {"from": account}) print(f"VRFCoordinator deployed to {vrf_coordinator.address}") print("All done!")

def fund_with_link( contract_address, account=None, link_token=None, amount=Web3.toWei(0.3, "ether") ): account = account if account else get_account() link_token = link_token if link_token else get_contract("link_token") funding_tx = link_token.transfer(contract_address, amount, {"from": account}) funding_tx.wait(1) print(f"Funded {contract_address}") return funding_tx` """

singhKaramjeet commented 2 years ago

Solved!!! you just have to add test folder in contracts folder you can just copy paste the previous test folder from smart lottery contracts

image

ariqbailey commented 2 years ago

Solved!!! you just have to add test folder in contracts folder you can just copy paste the previous test folder from smart lottery contracts

image

Thank you, this solved it for me! Happy New Years :)

PatrickAlphaC commented 2 years ago

Love seeing you work it out :)