| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $aa_name = "DANAA"; |
| 6 | $owner = "O7NYCFUL5XIJTYE3O4MKGMGMTN6ATQAJ"; |
| 7 | |
| 8 | $unit_id = trigger.data.unit_id; |
| 9 | $short_name = trigger.data.short_name; |
| 10 | $ticker = trigger.data.ticker; |
| 11 | $issuer = trigger.address; |
| 12 | $name = trigger.data.name otherwise $short_name||" by "||$issuer; |
| 13 | |
| 14 | }", |
| 15 | "messages": { |
| 16 | "cases": [ |
| 17 | { |
| 18 | "if": "{ $unit_id and $short_name and $ticker}", |
| 19 | "init": "{ |
| 20 | |
| 21 | if (trigger.data.decimals) |
| 22 | { |
| 23 | if (trigger.data.decimals < 0) |
| 24 | bounce ("'decimals' must be > 0 !"); |
| 25 | else |
| 26 | $decimals = trigger.data.decimals; |
| 27 | } |
| 28 | else |
| 29 | $decimals = 0; |
| 30 | |
| 31 | |
| 32 | if (var[$unit_id]) |
| 33 | if (trigger.address != var[$unit_id||"_issuer"]) |
| 34 | bounce ("Already registered and not by you !"); |
| 35 | |
| 36 | $description = trigger.data.description otherwise "Asset called "||$short_name||" issued by "||$issuer||", with "||$decimals||" decimals available. Its ticker is "||$ticker||" and it is defined by the unit '"||$unit_id||"'."; |
| 37 | }", |
| 38 | "messages": [ |
| 39 | { |
| 40 | "app": "payment", |
| 41 | "payload": { |
| 42 | "asset": "{'base'}", |
| 43 | "outputs": [ |
| 44 | { |
| 45 | "address": "{$issuer}", |
| 46 | "amount": "{trigger.output[[asset=base]] - 1000}" |
| 47 | } |
| 48 | ] |
| 49 | } |
| 50 | }, |
| 51 | { |
| 52 | "app": "state", |
| 53 | "state": "{ |
| 54 | var[$unit_id||"_shortName"] = $short_name; |
| 55 | var[$unit_id||"_issuer"] = $issuer; |
| 56 | var[$unit_id||"_name"] = $name; |
| 57 | var[$unit_id||"_ticker"] = $ticker; |
| 58 | var[$unit_id||"_decimals"] = $decimals; |
| 59 | var[$unit_id||"_description"] = $description; |
| 60 | }" |
| 61 | } |
| 62 | ] |
| 63 | }, |
| 64 | { |
| 65 | "messages": [ |
| 66 | { |
| 67 | "app": "state", |
| 68 | "state": "{ |
| 69 | bounce ("Specify the following fields: 'unit_id', 'shortname', 'ticker', 'decimal' and optionaly 'name, and description' that can be by default built from the previous fields."); |
| 70 | }" |
| 71 | } |
| 72 | ] |
| 73 | } |
| 74 | ] |
| 75 | } |
| 76 | } |
| 77 | ] |