| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $aa_name = "DANAA"; |
| 6 | $owner = "O7NYCFUL5XIJTYE3O4MKGMGMTN6ATQAJ"; |
| 7 | |
| 8 | $asset_unit_id = trigger.data.unit_id otherwise false; |
| 9 | $asset_new_name = trigger.data.new_name otherwise false; |
| 10 | $asset_author = trigger.address; |
| 11 | }", |
| 12 | "messages": { |
| 13 | "cases": [ |
| 14 | { |
| 15 | "if": "{ $asset_unit_id and $asset_new_name }", |
| 16 | "init": "{ |
| 17 | |
| 18 | if (var[$asset_unit_id]) |
| 19 | if (trigger.address != var[$asset_unit_id||"_author"]) |
| 20 | bounce ("Already registered and not by you!"); |
| 21 | }", |
| 22 | "messages": [ |
| 23 | { |
| 24 | "app": "payment", |
| 25 | "payload": { |
| 26 | "asset": "{'base'}", |
| 27 | "outputs": [ |
| 28 | { |
| 29 | "address": "{$asset_author}", |
| 30 | "amount": "{trigger.output[[asset=base]] - 1000}" |
| 31 | } |
| 32 | ] |
| 33 | } |
| 34 | }, |
| 35 | { |
| 36 | "app": "state", |
| 37 | "state": "{ |
| 38 | var[$asset_unit_id] = $asset_new_name; |
| 39 | var[$asset_unit_id||"_author"] = $asset_author; |
| 40 | }" |
| 41 | } |
| 42 | ] |
| 43 | }, |
| 44 | { |
| 45 | "messages": [ |
| 46 | { |
| 47 | "app": "state", |
| 48 | "state": "{ |
| 49 | bounce ("Specify a 'unit_id' and a 'new_name'"); |
| 50 | }" |
| 51 | } |
| 52 | ] |
| 53 | } |
| 54 | ] |
| 55 | } |
| 56 | } |
| 57 | ] |