Lesson 11: error: 'createCollectible Sequence has incorrect length, expected 1 but got 0' #500
-
|
Received the following error when trying to run Here is the corresponding scripts for: 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()
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!")
def main():
deploy_and_create()
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/{}/{}"
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:
- Get an address from the config
- Or deploy a Mock to use for a network that doesn't have the conract
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.
"""
# link_token
# LinkToken
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(1, "ether")):
account = account if account else get_account()
link_token = link_token if link_token else get_contract("link_token")
tx = link_token.transfer(contract_address, amount, {"from": account})
# link_token_contract = interface.LinkTokenInterface(link_token.address)
# tx = link_token_contract.transfer(contract_address, amount, {"from": account})
tx.wait(1)
print("Funded contract!")
return tx |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
Hello @brownandrew1390 I reviewed your code and seems everything is pretty much ok, your error is pointing to the ABI if yes, maybe brownie is reading incorrectly the ABI from the contract, so always is a good idea to delete the build folder and compile again. Also, could you please share the AdvancedCollectibl contract code here please? |
Beta Was this translation helpful? Give feedback.

Hello @brownandrew1390 I reviewed your code and seems everything is pretty much ok, your error is pointing to the ABI
data = format_input(self.abi, args), do you have this contract on your build folder?if yes, maybe brownie is reading incorrectly the ABI from the contract, so always is a good idea to delete the build folder and compile again.
Also, could you please share the AdvancedCollectibl contract code here please?