示例#1
0
def write_metadata(number_of_tokens, nft_contract):
    for token_id in range(number_of_tokens):
        collectible_metadata = sample_metadata.metadata_template
        breed = get_breed(nft_contract.tokenIdToBreed(token_id))
        metadata_file_name = ('./metadata/{}/'.format(network.show_active()) +
                              str(token_id) + '-' + breed + '.json')

        if Path(metadata_file_name).exists():
            print('{} already found!'.format(metadata_file_name))
        else:
            print('Creating Metadata File {}'.format(metadata_file_name))
            collectible_metadata['name'] = get_breed(
                nft_contract.tokenIdToBreed(token_id))
            collectible_metadata[
                'description'] = 'An adorable {} puppy!'.format(
                    collectible_metadata['name'])
            print(collectible_metadata)
            image_to_upload = None
            if os.getenv('UPLOAD_IPFS') == 'true':
                image_path = "./img/{}.png".format(breed.lower().replace(
                    '_', '-'))
                image_to_upload = upload_to_ipfs(image_path)
            collectible_metadata['image'] = image_to_upload
            with open(metadata_file_name, 'w') as file:
                json.dump(collectible_metadata, file)
            if os.getenv('UPLOAD_IPFS') == 'true':
                upload_to_ipfs(metadata_file_name)
示例#2
0
def write_metadata(token_ids, nft_contract):
    for token_id in range(token_ids):
        collectible_metadata = sample_metadata.metadata_template
        breed = get_breed(nft_contract.tokenIdToBreed(token_id))
        metadata_file_name = (
            "./metadata/{}/".format(network.show_active())
            + str(token_id)
            + "-"
            + breed
            + ".json"
        )
        if Path(metadata_file_name).exists():
            print(
                "{} already found, delete it to overwrite!".format(metadata_file_name)
            )
            continue
        else:
            print("Creating Metadata file: " + metadata_file_name)
            collectible_metadata["name"] = get_breed(
                nft_contract.tokenIdToBreed(token_id)
            )
            collectible_metadata["description"] = "An adorable {} pup!".format(
                collectible_metadata["name"]
            )
            if os.getenv("UPLOAD_IPFS") == "true":
                pug_uri = upload_nft()
            collectible_metadata["image"] = pug_uri
            file = open(metadata_file_name, "w")
            json.dump(collectible_metadata, file)
示例#3
0
def write_metadata(token_ids, nft_contract):
    for token_id in range(token_ids):
        collectible_metadata = sample_metadata.metadata_template
        breed = get_breed(nft_contract.tokenIdToBreed(token_id))
        metadata_file_name = ("./metadata/{}/".format(network.show_active()) +
                              str(token_id) + "-" + breed + ".json")
        if Path(metadata_file_name).exists():
            print("{} already found, delete it to overwrite!".format(
                metadata_file_name))
        else:
            print("Creating Metadata file: " + metadata_file_name)
            collectible_metadata["name"] = get_breed(
                nft_contract.tokenIdToBreed(token_id))
            collectible_metadata["description"] = "An adorable {} pup!".format(
                collectible_metadata["name"])
            image_to_upload = None
            if os.getenv("UPLOAD_IPFS") == "true":
                image_path = "./img/{}.png".format(breed.lower().replace(
                    '_', '-'))
                image_to_upload = upload_to_ipfs(image_path)
            image_to_upload = (breed_to_image_uri[breed]
                               if not image_to_upload else image_to_upload)
            collectible_metadata["image"] = image_to_upload
            with open(metadata_file_name, "w") as file:
                json.dump(collectible_metadata, file)
            if os.getenv("UPLOAD_IPFS") == "true":
                upload_to_ipfs(metadata_file_name)
示例#4
0
def main():
    dev = accounts.add(config['wallets']['from_key'])
    advanced_collectible = AdvancedCollectible[len(AdvancedCollectible) - 1]
    transaction = advanced_collectible.createCollectible(
        STATIC_SEED, 'None', {'from': dev})
    transaction.wait(1)
    time.sleep(35)
    requestId = transaction.events['requestedCollectible']['requestId']
    token_id = advanced_collectible.requestIdToTokenId(requestId)
    breed = get_breed(advanced_collectible.tokenIdToBreed(token_id))
    print('Dog breed of tokenId {} is {}'.format(token_id, breed))
示例#5
0
def main():
    dev = accounts.add(config["wallets"]["from_key"])
    advanced_collectible = AdvancedCollectible[len(AdvancedCollectible) - 1]
    fund_advanced_collectible(advanced_collectible)
    transaction = advanced_collectible.createCollectible(
        "None", STATIC_SEED, {"from": dev})
    print("Waiting on second transaction...")
    # wait for the 2nd transaction
    time.sleep(60)
    requestId = transaction.events["requestedCollectible"]["requestId"]
    token_id = advanced_collectible.requestIdToTokenId(requestId)
    breed = get_breed(advanced_collectible.tokenIdToBreed(token_id))
    print("Dog breed of tokenId {} is {}".format(token_id, breed))
示例#6
0
def main():
    print("Working on " + network.show_active())
    advanced_collectible = AdvancedCollectible[len(AdvancedCollectible) - 1]
    number_of_advanced_collectibles = advanced_collectible.tokenCounter()
    print("The number of tokens you've deployed is: " +
          str(number_of_advanced_collectibles))
    for token_id in range(number_of_advanced_collectibles):
        breed = get_breed(advanced_collectible.tokenIdToBreed(token_id))
        if not advanced_collectible.tokenURI(token_id).startswith("https://"):
            print("Setting tokenURI of {}".format(token_id))
            set_tokenURI(token_id, advanced_collectible,
                         dog_metadata_dic[breed])
        else:
            print(
                "Skipping {}, we already set that tokenURI!".format(token_id))
def main():
    dev = accounts.add(config["wallets"]["from_key"])
    advanced_collectible = AdvancedCollectible[len(AdvancedCollectible) - 1]
    fund_with_link(advanced_collectible.address)
    transaction = advanced_collectible.createCollectible("None", {"from": dev})
    print("Waiting on second transaction...")
    # wait for the 2nd transaction
    transaction.wait(1)
    # time.sleep(35)
    listen_for_event(advanced_collectible,
                     "ReturnedCollectible",
                     timeout=200,
                     poll_interval=10)
    requestId = transaction.events["RequestedCollectible"]["requestId"]
    token_id = advanced_collectible.requestIdToTokenId(requestId)
    breed = get_breed(advanced_collectible.tokenIdToBreed(token_id))
    print("Dog breed of tokenId {} is {}".format(token_id, breed))