Closed ariqbailey closed 2 years ago
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:
Or deploy a Mock to use for a network that doesn't have the contract
Args: contract_name (string): This is the name of the contract that we will get from the config or deploy
Returns: brownie.network.contract.ProjectContract: This is the most recently deployed Contract of the type specified by a dictionary. This could either be a mock or a 'real' contract on a live network. """
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] contract = Contract.from_abi( contract_type._name, contract_address, contract_type.abi ) return contract
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` """
Solved!!! you just have to add test folder in contracts folder you can just copy paste the previous test folder from smart lottery contracts
Solved!!! you just have to add test folder in contracts folder you can just copy paste the previous test folder from smart lottery contracts
Thank you, this solved it for me! Happy New Years :)
Love seeing you work it out :)
i am having the same error