| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "bounce_fees": { |
| 5 | "base": 10000 |
| 6 | }, |
| 7 | "getters": "{ |
| 8 | $validate = $asset =>{ |
| 9 | $unitInfo = unit[$asset]; |
| 10 | if (NOT $unitInfo.messages) |
| 11 | return false; |
| 12 | $schema = $unitInfo.authors[0].authentifiers |
| 13 | ? false |
| 14 | : $unitInfo.authors[0].address; |
| 15 | if (NOT $schema) |
| 16 | return false; |
| 17 | if ($schema != this_address) |
| 18 | return false; |
| 19 | |
| 20 | return true; |
| 21 | }; |
| 22 | }", |
| 23 | "init": "{ |
| 24 | $BOUNCER = "CFUQKRS37OGK4NDQRI6VHFNWTGHHAJAC"; |
| 25 | $sendAsset = var[trigger.initial_address]; |
| 26 | response["sendAsset"] = $sendAsset; |
| 27 | if (NOT $sendAsset AND NOT exists(trigger.data["title"])) |
| 28 | bounce("title field is mandatory"); |
| 29 | if (trigger.data){ |
| 30 | if (NOT exists(trigger.data["title"])) |
| 31 | bounce("title field is mandatory"); |
| 32 | if (NOT exists(trigger.data["ipfs"])) |
| 33 | bounce("ipfs field is mandatory"); |
| 34 | if (NOT exists(trigger.data["type"])) |
| 35 | bounce("type field is mandatory"); |
| 36 | if (length(trigger.data["type"]) > 16) |
| 37 | bounce("type field must be shorter than 16 characters"); |
| 38 | if (exists(trigger.data["ticker"])){ |
| 39 | if (length(trigger.data["ticker"]) > 5) |
| 40 | bounce("ticker field must be shorter than 5 characters"); |
| 41 | } |
| 42 | if (NOT exists(trigger.data["copies"])) |
| 43 | bounce("copies field is mandatory"); |
| 44 | if (NOT is_integer(trigger.data["copies"])) |
| 45 | bounce("copies field must be an integer"); |
| 46 | if (trigger.data["copies"] < 1) |
| 47 | bounce("copies must be at least 1"); |
| 48 | if (exists(trigger.data["royalty"])){ |
| 49 | if (NOT is_integer(trigger.data["royalty"])) |
| 50 | bounce("royalty field must be an integer"); |
| 51 | if (trigger.data["royalty"] < 0) |
| 52 | bounce("royalty cannot be negative"); |
| 53 | if (trigger.data["royalty"] > 100) |
| 54 | bounce("royalty can't be higher than 100"); |
| 55 | } |
| 56 | } |
| 57 | }", |
| 58 | "messages": [ |
| 59 | { |
| 60 | "app": "asset", |
| 61 | "if": "{exists(trigger.data["title"])}", |
| 62 | "payload": { |
| 63 | "cap": "{trigger.data["copies"]}", |
| 64 | "is_private": false, |
| 65 | "is_transferrable": true, |
| 66 | "auto_destroy": "{trigger.data["burn"]}", |
| 67 | "fixed_denominations": false, |
| 68 | "issued_by_definer_only": true, |
| 69 | "cosigned_by_definer": false, |
| 70 | "spender_attested": false |
| 71 | } |
| 72 | }, |
| 73 | { |
| 74 | "app": "payment", |
| 75 | "payload": { |
| 76 | "asset": "base", |
| 77 | "outputs": [ |
| 78 | { |
| 79 | "address": "{trigger.address == $BOUNCER ? trigger.initial_address : $BOUNCER}" |
| 80 | } |
| 81 | ] |
| 82 | } |
| 83 | }, |
| 84 | { |
| 85 | "if": "{$sendAsset}", |
| 86 | "app": "payment", |
| 87 | "payload": { |
| 88 | "asset": "{$sendAsset}", |
| 89 | "outputs": [ |
| 90 | { |
| 91 | "address": "{trigger.initial_address}", |
| 92 | "amount": "{asset[$sendAsset].cap}" |
| 93 | } |
| 94 | ] |
| 95 | } |
| 96 | }, |
| 97 | { |
| 98 | "app": "state", |
| 99 | "state": "{ |
| 100 | var[trigger.address] = exists(trigger.data["title"]) ? response_unit : false; |
| 101 | }" |
| 102 | } |
| 103 | ] |
| 104 | } |
| 105 | ] |