[
"autonomous agent",
{
"bounce_fees": {
"base": 10000
},
"init": "{
$HOUSE_CUT = 0.15;
}",
"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"] //Invoked by the Owner
AND trigger.data["method"] == "mint" //Method is mint
AND is_valid_amount(trigger.data["amount"]) //The amount of NFTs to emit is valid
AND exists(trigger.data["ipfsHash"]) //The IPFS hash has been submitted
AND is_integer(trigger.data["endTime"]) //The endTime is an integer
AND trigger.data["endTime"] > timestamp //The endTime is set in the future
}",
"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 || "_name"] = trigger.data["name"]?trigger.data["name"]:"Unnamed";//User-friendly artwork name
var[response_unit || "_bid"] = 0; //Max current bid
var[response_unit || "_at"] = timestamp; //Max bid time
var[response_unit || "_mintedAt"] = timestamp; //Mint date
var[response_unit || "_ipfsHash"] = trigger.data["ipfsHash"]; //Hash of the content
var[response_unit || "_author"] = trigger.address; //The original seller
var[response_unit || "_soldAt"] = trigger.data["endTime"]; //End of the auction
var[response_unit || "_soldBy"] = trigger.address; //Who is currently selling the NFT
}"
}
]
},
{
"if": "{
is_valid_amount(trigger.data["price"]) //The price is correct
}",
"messages": [
{
"app": "asset",
"payload": {
"cap": "{trigger.data["cap"]}",
"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 || "_name"] = trigger.data["name"]?trigger.data["name"]:"Unnamed";//User-friendly artwork name
var[response_unit || "_price"] = trigger.data["price"]; //Price per NFT
var[response_unit || "_mintedAt"] = timestamp; //Mint date
var[response_unit || "_ipfsHash"] = trigger.data["ipfsHash"]; //Hash of the content
var[response_unit || "_author"] = trigger.address; //The original seller
var[response_unit || "_soldAt"] = trigger.data["endTime"]; //End of the sale, remaining tokens will be unusable
var[response_unit || "_soldBy"] = trigger.address; //Who is currently selling the NFT
}"
}
]
}
]
}
},
{
"if": "{
trigger.address == var["owner"] //Invoked by the Owner
AND trigger.data["method"] == "payout" //Method is payout
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{var["owner"]}"
}
]
}
}
]
},
{
"if": "{
trigger.address == var["owner"] //Execution is invoked by the Owner
AND trigger.data["method"] == "revoke" //Method is revoke
AND exists(trigger.data["NFT"]) //The NFT parameter is passed
AND exists(trigger.data["reason"]) //The reason parameter is passed
}",
"messages": [
{
"app": "data_feed",
"payload": {
"{"REVOCATION_REASON_" || trigger.data["NFT"]}": "{trigger.data["reason"]}"
}
}
]
},
{
"if": "{
trigger.address == var["owner"] //Invoked by the Owner
AND trigger.data["method"] == "transferOwnership" //Trigger method is transferOwnership
AND is_valid_address(trigger.data["newOwner"]) //The new Owner address is valid
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{var["owner"]}"
}
]
}
},
{
"app": "state",
"state": "{
var["owner"] = trigger.data["newOwner"]; //Ownership is transferred
}"
}
]
},
{
"if": "{
timestamp < var[trigger.data['NFT'] || "_soldAt"] //The timestamp is set before the end date
}",
"messages": {
"cases": [
{
"if": "{
balance[trigger.data["NFT"]] > 0 //The AA currently holds more than 0 of the given NFT
AND trigger.output[[asset=base]] >= var[trigger.data['NFT'] || "_price"] //The AA received more than the sell price
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{var[trigger.data['NFT'] || "_soldBy"]}",
"amount": "{floor(trigger.output[[asset=base]] * (1-$HOUSE_CUT), 0)}"
}
]
}
},
{
"app": "payment",
"payload": {
"asset": "{trigger.data['NFT']}",
"outputs": [
{
"address": "{trigger.address}",
"amount": 1
}
]
}
}
]
},
{
"if": "{
trigger.output[[asset=base]] > floor(var[trigger.data['NFT'] || "_bid"], 0) //The transaction is > than the max bid
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{var[trigger.data['NFT'] || "_by"]}",
"amount": "{var[trigger.data['NFT'] || "_bid"]}"
}
]
}
},
{
"app": "state",
"state": "{
var[trigger.data['NFT'] || "_bid"] = trigger.output[[asset=base]];
var[trigger.data['NFT'] || "_by"] = trigger.address;
}"
}
]
}
]
}
},
{
"if": "{
trigger.data["method"] == "SELL" //Method is SELL
AND trigger.output[[asset!=base]].amount==1 //Only 1 NFT is sold at a time
AND NOT in_data_feed[[oracles=this_address, feed_name="REVOCATION_REASON_" || trigger.output[[asset!=base]], feed_value=trigger.output[[asset!=base]]]]//The NFT is NOT revoked
AND var[trigger.output[[asset!=base]] || "_mintedAt"] == 0 //The NFT is in our registry
AND var[trigger.output[[asset!=base]] || "_soldAt"] < timestamp //The token is currently NOT being sold (this includes no copy is being sold at this time)
AND is_valid_amount(trigger.data["startingPrice"]) //The user supplied the starting bidding price
AND trigger.data["endTime"] > timestamp //The end date timestamp supplied by the user is set in the future
}",
"messages": [
{
"app": "state",
"state": "{
var[trigger.output[[asset!=base]] || "_bid"] = trigger.data["startingPrice"];
var[trigger.output[[asset!=base]] || "_by"] = trigger.address;
var[trigger.output[[asset!=base]] || "_soldBy"] = trigger.address;
var[trigger.output[[asset!=base]] || "_at"] = timestamp;
var[trigger.output[[asset!=base]] || "_soldAt"] = trigger.data["endTime"];
}"
}
]
},
{
"if": "{
timestamp > var[trigger.data['NFT'] || "_soldAt"] //La subasta ha acabado
AND ((trigger.address == var[trigger.data['NFT'] || "_by"]) || (trigger.address == var[trigger.data['NFT'] || "_soldBy"])) //Invocado por el vendedor o el comprador
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{var[trigger.data['NFT'] || "_soldBy"]}",
"amount": "{floor(trigger.output[[asset=base]] * (1-$HOUSE_CUT), 0)}"
}
]
}
},
{
"app": "payment",
"payload": {
"asset": "{trigger.data['NFT']}",
"outputs": [
{
"address": "{var[trigger.data['NFT'] || "_by"]}",
"amount": 1
}
]
}
},
{
"app": "data_feed",
"payload": {
"{trigger.data['NFT']}": "{{
name: var[trigger.data['NFT'] || "_name"],
author: var[trigger.data['NFT'] || "_author"],
ipfsHash: var[trigger.data['NFT'] || "_ipfsHash"]
}}"
}
}
]
}
]
}
}
]