Unit ID
Lm9zGlJHbKOJOAOlufrxNsoVfCJ+q+PfHpMRMM61vLE=
Received
22.03.2021 04:08:59
Confirmation delay (full node)
2 minutes 56 seconds
Confirmation delay (light node)
3 minutes 28 seconds
Messages
Definition
Definition: [ "autonomous agent", { "bounce_fees": { "base": 10000 }, "init": "{ $HOUSE_CUT = 0.15; //We will take this cut on the debut of an NFT in our platform $ARTIST_CUT = 0.01; //The artist will get this cut from every resale of their NFT }", "getters": "{ $tokenInfo = $NFT => data_feed[[oracles=this_address, feed_name=$NFT]] || {isBanned: in_data_feed[[oracles=this_address, feed_name="REVOCATIONS", feed_value=$NFT]]}; }", "messages": { "cases": [ { "if": "{ NOT var["owner"] //The owner has not been set }", "messages": [ { "app": "state", "state": "{ var["owner"] = "IUU43O7TS2TBYKAPGKUARDZHOTAE275A"; //Set the Owner to my address }" } ] }, { "if": "{ trigger.address == var["owner"] }", "init": "{ if (NOT exists(trigger.data["method"])) bounce("method field is mandatory"); }", "messages": { "cases": [ { "if": "{ trigger.data["method"] == "mint" }", "init": "{ if (NOT exists(trigger.data["amount"])) bounce("amount field is mandatory"); if (NOT is_valid_amount(trigger.data["amount"])) bounce("The amount of NFT copies to mint is not valid"); if (NOT exists(trigger.data["ipfs"])) bounce("ipfs field is mandatory"); if (NOT exists(trigger.data["seller"])) bounce("seller field is mandatory"); if (NOT is_valid_address(trigger.data["seller"])) bounce("The seller address is not valid"); if (NOT exists(trigger.data["endTime"])) bounce("endTime field is mandatory"); if (NOT is_integer(trigger.data["endTime"])) bounce("endTime field is not a timestamp"); if (trigger.data["endTime"] <= timestamp) bounce("The endTime cannot be set in the past"); }", "messages": { "cases": [ { "if": "{ trigger.data["amount"] == 1 }", "messages": [ { "app": "asset", "payload": { "cap": 1, "is_private": false, "is_transferrable": true, "auto_destroy": false, "fixed_denominations": false, "issued_by_definer_only": true, "cosigned_by_definer": false, "spender_attested": false } }, { "app": "state", "state": "{ var[response_unit] = { bid: 0, //Max current bid (a NFT can have this field because it was resold. Check for price field instead) at: timestamp, //Max bid time mintedAt: timestamp, //Mint date ipfs: trigger.data["ipfs"], //Hash of the content author: trigger.data["seller"], //The original seller soldAt: trigger.data["endTime"], //End of the auction soldBy: trigger.data["seller"] //Who is currently selling the NFT }; }" } ] }, { "init": "{ if (NOT exists(trigger.data["price"])) bounce("price field is mandatory if you intend to sell more than one NFT copy"); if (NOT is_valid_amount(trigger.data["price"])) bounce("price is not valid"); }", "messages": [ { "app": "asset", "payload": { "cap": "{trigger.data["amount"]}", "is_private": false, "is_transferrable": true, "auto_destroy": false, "fixed_denominations": false, "issued_by_definer_only": true, "cosigned_by_definer": false, "spender_attested": false } }, { "app": "state", "state": "{ var[response_unit] = { price: trigger.data["price"], //Sale price (this field is only present if the first sale was a fixed price one) at: timestamp, //Max bid time mintedAt: timestamp, //Mint date ipfs: trigger.data["ipfs"], //Hash of the content author: trigger.data["seller"], //The original seller soldAt: trigger.data["endTime"], //End of the auction soldBy: trigger.data["seller"] //Who is currently selling the NFT }; }" } ] } ] } }, { "if": "{ trigger.data["method"] == "payout" }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{trigger.address}" } ] } } ] }, { "if": "{ trigger.data["method"] == "revoke" }", "init": "{ if (NOT exists(trigger.data["NFT"])) bounce("NFT field is mandatory"); }", "messages": [ { "app": "data_feed", "payload": { "{"REVOCATIONS"}": "{trigger.data["NFT"]}" } } ] }, { "if": "{ trigger.data["method"] == "transferOwnership" }", "init": "{ if (NOT exists(trigger.data["newOwner"])) bounce("newOwner field is mandatory"); if (NOT is_valid_address(trigger.data["newOwner"])) bounce("newOwner field is not a valid address"); }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{trigger.address}" } ] } }, { "app": "state", "state": "{ var["owner"] = trigger.data["newOwner"];//Ownership is transferred }" } ] } ] } }, { "if": "{ trigger.data["method"] == "BUY" }", "init": "{ if (NOT exists (trigger.data["NFT"])) bounce("NFT field is mandatory"); $NFT = var[trigger.data["NFT"]]; if (NOT $NFT) bounce("This NFT was not minted by us nor we listed it for sale"); if (timestamp >= $NFT.soldAt) bounce("The auction is over"); }", "messages": { "cases": [ { "if": "{ typeof($NFT.bid) == "number" //It is an auction }", "init": "{ if (trigger.output[[asset=base]].amount <= $NFT.bid) bounce("Your bid is lower or equal to the last bid. You must increase it"); }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$NFT.by}", "amount": "{$NFT.bid}" } ] } }, { "app": "state", "state": "{ $NFT.bid = trigger.output[[asset=base]].amount; $NFT.by = trigger.address; var[trigger.data["NFT"]] ||= $NFT; }" } ] }, { "if": "{ balance[trigger.data["NFT"]] > 0 //The AA currently holds more than 0 of the given NFT }", "init": "{ if (trigger.output[[asset=base]].amount <= $NFT.price) bounce("Your payment is lower than the NFT price"); }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$NFT.soldBy}", "amount": "{floor($NFT.price * (1-$HOUSE_CUT), 0)}" } ] } }, { "app": "payment", "payload": { "asset": "{trigger.data['NFT']}", "outputs": [ { "address": "{trigger.address}", "amount": 1 } ] } } ] } ] } }, { "if": "{ trigger.data["method"] == "CLAIM" }", "init": "{ if (NOT exists(trigger.data["NFT"])) bounce("NFT field is mandatory"); $NFT = var[trigger.data["NFT"]]; //Do NOT check for the NFT in the data_feed as it is not yet there if (timestamp <= $NFT.soldAt) bounce("The auction is not over yet"); }", "messages": { "cases": [ { "if": "{//NFT was first sold NOT in_data_feed[[oracles=this_address, feed_name=trigger.data['NFT'], feed_value=$NFT.ipfsMeta]] }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$NFT.soldBy}", "amount": "{floor($NFT.bid * (1-$HOUSE_CUT), 0)}" } ] } }, { "app": "payment", "payload": { "asset": "{trigger.data['NFT']}", "outputs": [ { "address": "{$NFT.by}", "amount": 1 } ] } }, { "app": "data_feed", "payload": { "{trigger.data['NFT']}": "{$NFT.ipfsMeta}" } } ] }, { "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$NFT.soldBy}", "amount": "{floor($NFT.bid * (1-$ARTIST_CUT), 0)}" } ] } }, { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$NFT.author}", "amount": "{floor($NFT.bid * $ARTIST_CUT, 0)}" } ] } }, { "app": "payment", "payload": { "asset": "{trigger.data['NFT']}", "outputs": [ { "address": "{$NFT.by}", "amount": 1 } ] } } ] } ] } }, { "if": "{//[PUBLIC] Resell a NFT trigger.data["method"] == "SELL" }", "init": "{ $NFT = var[trigger.output[[asset!=base]].asset]; if (NOT $NFT) bounce("This NFT was not minted by us nor we listed it for sale"); if (trigger.output[[asset!=base]].amount!=1) bounce("You cannot auction more than 1 copy of an NFT at a time"); if (in_data_feed[[oracles=this_address, feed_name="REVOCATIONS", feed_value=trigger.output[[asset!=base]].asset]]) bounce("We revoked the trading of that token probably due to copyright reasons"); if (NOT $NFT.soldAt >= timestamp) bounce("A copy of that NFT is already being auctioned. Please try again after" || timestamp_to_string($NFT.soldAt)); if (NOT is_valid_amount(trigger.data["startingPrice"])) bounce("The initial price must be a valid amount"); if (trigger.data["endTime"] < timestamp) bounce("You cannot set the end time in the past"); }", "messages": [ { "app": "state", "state": "{ $NFT.bid = trigger.data["startingPrice"]; $NFT.by = trigger.address; $NFT.soldBy = trigger.address; $NFT.at = timestamp; $NFT.soldAt = trigger.data["endTime"]; var[trigger.output[[asset!=base]].asset] ||= $NFT; }" } ] } ] } } ]
Technical information
Fees:
8,700 bytes
(452 headers, 8248 payload)
Level:1927343
Witnessed level:1927336
Main chain index:1919378
Latest included mc index:1919377
Status:stable/confirmed/final