Transaction #6590

Hash dbad38ebc0e9cdae48924982684b72c71e18cefcc26a6a57d7757f88a6bc27fb
Status Failed
Error Message Exception('Contract already exists.',)
Timestamp 433 days ago - 2/24/2023, 10:07:49 AM UTC+0
Block 6590
Stamps Used 8
Burned Fee 0.00047337 TAU
From d4a1561ae09b8c0a978a1334b33744262c0edeea1940998bf7035808362d5d11 
Contract Name submission
Function Name submit_contract

Additional Info
Nonce 0
Processor 11185fe3c6e68d11f89929e2f531de3fb640771de1aee32c606c30c70b6600d2
Signature 1eb4023197de97457e06bbed8acd8205d38bf2686d36ea8bc6d7c27ab7049286ec6bff0ad98df6783ba941c1e21d382bcc24de616facbed09c7c7c60a27b040f
Stamps Supplied 500
Stamps per TAU 169

Kwargs

code I = importlib collection_name = Variable() collection_owner = Variable() collection_nfts = Hash(default_value=0) collection_balances = Hash(default_value=0) collection_balances_approvals = Hash(default_value=0) @construct def seed(): collection_name.set("Bad Bunny") collection_owner.set(ctx.caller) @export def mint_nft(name: str, description: str, ipfs_image_url: str, metadata: dict, amount: int): assert name != "", "Name cannot be empty" assert collection_nfts[name] == 0, "Name already exists" assert amount > 0, "You cannot transfer negative amounts" assert collection_owner.get() == ctx.caller, "Only the collection owner can mint NFTs" collection_nfts[name] = {"description": description, "ipfs_image_url": ipfs_image_url, "metadata": metadata, "amount": amount} collection_balances[ctx.caller, name] = amount @export def transfer(name: str, amount:int, to: str): assert amount > 0, "You cannot transfer negative amounts" assert name != "", "Please specify the name of the NFT you want to transfer" assert collection_balances[ctx.caller, name] >= amount, "You dont have enough NFTs to send" collection_balances[ctx.caller, name] -= amount collection_balances[to, name] += amount # Adds amount to receiver @export def approve(amount: int, name: str, to: str): assert amount > 0, "Cannot approve negative amounts" collection_balances_approvals[ctx.caller, to, name] += amount @export def transfer_from(name:str, amount:int, to: str, main_account: str): assert amount > 0, "Cannot send negative balances!" assert collection_balances_approvals[main_account, to, name] >= amount, "Not enough NFTs approved to send! You have {} and are trying to spend {}".format(collection_balances_approvals[main_account, to, name], amount) assert collection_balances[main_account, name] >= amount, "Not enough NFTs to send!" collection_balances_approvals[main_account, to, name] -= amount collection_balances[main_account, name] -= amount collection_balances[to, name] += amount @export def setup_redeem(name: str, redeem_type: str, redeem_contract: str, redeem_amount: float): assert collection_owner.get() == ctx.caller, "You are not the collection creator" assert collection_nfts[name] != 0, f"NFT {name} doesnt exist" assert redeem_type.lower() in ["lp", "token"], "Only redeem types lp and token supported" nft_data = collection_nfts[name] assert "redeem_type" not in nft_data, "NFT is already redeemable!" nft_data["redeem_type"] = redeem_type.lower() nft_data["redeem_contract"] = redeem_contract nft_data["redeem_amount"] = redeem_amount collection_nfts[name] = nft_data # Transfer token if redeem_type.lower() == "token": I.import_module(redeem_contract).transfer_from( amount=redeem_amount, to=ctx.this, main_account=ctx.caller) # Transfer LP elif redeem_type.lower() == "lp": I.import_module("con_rocketswap_official_v1_1").transfer_liquidity_from( contract=redeem_contract, amount=redeem_amount, to=ctx.this, main_account=ctx.caller) @export def redeem(name: str): assert collection_nfts[name] != 0, f"NFT {name} doesnt exist" nft_data = collection_nfts[name] assert "redeem_type" in nft_data, "NFT is not redeemable!" # Get redeem amount for one NFT redeem_amount = nft_data["redeem_amount"] nft_amount = nft_data["amount"] amount = redeem_amount / nft_amount # Transfer redeemable amount if nft_data["redeem_type"].lower() == "token": I.import_module(nft_data["redeem_contract"]).transfer(amount=amount, to=ctx.caller) elif nft_data["redeem_type"].lower() == "lp": I.import_module("con_rocketswap_official_v1_1").transfer_liquidity(contract=nft_data["redeem_contract"], amount=amount, to=ctx.caller) # Burn NFT approve(name=name, amount=1, to=ctx.this) transfer_from(name=name, amount=1, to=ctx.this, main_account=ctx.caller)
name con_nft_bad_bunny

State Changes

Contract currency
Variable balances
Key d4a1561ae09b8c0a978a1334b33744262c0edeea1940998bf7035808362d5d11
New Value 495.917159763313609375