Unit ID
yU5bOU9jcXBVvaMd0tWzYE8WIVVGVTu9m7aFe43bCFs=
Received
02.09.2024 16:33:12
Confirmation delay (full node)
16 minutes 43 seconds
Messages
Definition
Definition: [ "autonomous agent", { "init": "{ $id = trigger.data.id; }", "messages": { "cases": [ { "if": "{trigger.data.register AND $id}", "init": "{ if (var['owner' || $id]) bounce('thing ' || $id || ' already registered'); if (trigger.data.sell){ $price = trigger.data.price; if (!$price || !($price > 0) || round($price) != $price) bounce('please set a positive integer price'); } }", "messages": [ { "app": "state", "state": "{ var['owner' || $id] = trigger.address; if (trigger.data.sell AND trigger.data.price) var['price' || $id] = trigger.data.price; response['message'] = 'registered' || (trigger.data.sell AND trigger.data.price ? ' and put on sale for ' || trigger.data.price : ''); }" } ] }, { "if": "{$id AND trigger.data.sell AND trigger.data.price}", "init": "{ $owner = var['owner' || $id]; if (!$owner OR $owner != trigger.address) bounce('thing ' || $id || ' is not yours'); if (!(trigger.data.price > 0) OR round(trigger.data.price) != trigger.data.price) bounce('please set an integer positive price'); }", "messages": [ { "app": "state", "state": "{ var['price' || $id] = trigger.data.price; response['message'] = 'on sale for ' || trigger.data.price; }" } ] }, { "if": "{$id AND trigger.data.withdraw_from_sale}", "init": "{ $owner = var['owner' || $id]; if (!$owner OR $owner != trigger.address) bounce('thing ' || $id || ' is not yours'); }", "messages": [ { "app": "state", "state": "{ var['price_' || $id] = false; // no-price means not on sale response['message'] = 'withdrawn from sale'; }" } ] }, { "if": "{$id AND trigger.data.buy}", "init": "{ $owner = var['owner' || $id]; if (!$owner) bounce('no such thing: ' || $id); if ($owner == trigger.address) bounce('thing ' || $id || ' is already yours'); $price = var['price' || $id]; if (!$price) bounce('thing ' || $id || ' is not on sale'); $amount = trigger.output[[asset=base]]; if ($amount < $price) bounce("the thing's price is " || $price || ", you sent only " || $amount); $change = $amount - $price; }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$owner}", "amount": "{$price}" }, { "if": "{$change > 0}", "address": "{trigger.address}", "amount": "{$change}" } ] } }, { "app": "state", "state": "{ var['owner' || $id] = trigger.address; // new owner var['price' || $id] = false; // not on sale any more response['message'] = 'sold to ' || trigger.address; }" } ] } ] } } ]
Technical information
Fees:
3,213 bytes
(451 headers, 2762 payload)
Level:11221802
Witnessed level:11221790
Main chain index:10834507
Latest included mc index:10834506
Status:stable/confirmed/final