[
"autonomous agent",
{
"bounce_fees": {
"base": 10000
},
"init": "{
$HOUSE_CUT = 0.15;
}",
"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"]
}",
"messages": {
"cases": [
{
"if": "{
trigger.data["method"] == "mint"
}",
"messages": {
"cases": [
{
"if": "{
is_valid_amount(trigger.data["amount"]) //The amount of minted NFTs is valid
AND exists(trigger.data["ipfs"]) //The IPFS hash has been submitted
AND exists(trigger.data["meta"]) //The IPFS hash has been submitted
AND exists(trigger.data["seller"])
AND is_valid_address(trigger.data["seller"])//Check seller is valid
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] = {
bid: 0, //Max current bid
at: timestamp, //Max bid time
mintedAt: timestamp, //Mint date
ipfsMeta: trigger.data["meta"], //IPFS hash to a JSON document describing the file
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": "{
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] = {
price: trigger.data["price"], //Max current bid
at: timestamp, //Max bid time
mintedAt: timestamp, //Mint date
ipfsMeta: trigger.data["meta"], //IPFS hash to a JSON document describing the file
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"
}",
"messages": {
"cases": [
{
"if": "{
exists(trigger.data["NFT"]) //The NFT parameter is passed
}",
"messages": [
{
"app": "data_feed",
"payload": {
"{"REVOCATIONS"}": "{trigger.data["NFT"]}"
}
}
]
}
]
}
},
{
"if": "{
trigger.data["method"] == "transferOwnership"
}",
"messages": {
"cases": [
{
"if": "{
is_valid_address(trigger.data["newOwner"]) //The new Owner address is valid
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{trigger.address}"
}
]
}
},
{
"app": "state",
"state": "{
var["owner"] = trigger.data["newOwner"];//Ownership is transferred
}"
}
]
}
]
}
}
]
}
},
{
"if": "{
$NFT = var[trigger.data["NFT"]];
timestamp < $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]].amount >= $NFT.price //The AA received more than the sell 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.output[[asset=base]].amount > $NFT.bid //The bid is higher than the previous one
}",
"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": "{
$NFT = var[trigger.data["NFT"]];
timestamp > $NFT.soldAt //Auction is over
AND (trigger.address == $NFT.by OR trigger.address == $NFT.soldBy) //Invoked by buyer or seller
}",
"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
}
]
}
},
{
"if": "{
NOT in_data_feed[[oracles=this_address, feed_name="REVOCATIONS", feed_value=trigger.data["NFT"]]]
}",
"app": "data_feed",
"payload": {
"{trigger.data['NFT']}": "{$NFT.ipfsMeta}"
}
}
]
},
{
"if": "{
$NFT = var[trigger.output[[asset!=base]].asset];
$NFT
AND 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="REVOCATIONS", feed_value=trigger.output[[asset!=base]].asset]] //The NFT is NOT revoked
AND $NFT.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": "{
$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;
}"
}
]
}
]
}
}
]