| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "bounce_fees": { |
| 5 | "base": 10000 |
| 6 | }, |
| 7 | "init": "{ |
| 8 | |
| 9 | $amount = trigger.data.amount; |
| 10 | $destination = trigger.data.destination_address; |
| 11 | $hash = trigger.data.hash_of_secret; |
| 12 | }", |
| 13 | "messages": { |
| 14 | "cases": [ |
| 15 | { |
| 16 | "if": "{ !!$amount and !!$destination and !!$hash }", |
| 17 | "init": "{ |
| 18 | $asset = trigger.data.asset_id otherwise "base"; |
| 19 | $duration = trigger.data.duration_in_hours otherwise 1; |
| 20 | $deadline = timestamp + (json_parse($duration) * 60 * 60); |
| 21 | }", |
| 22 | "messages": [ |
| 23 | { |
| 24 | "app": "definition", |
| 25 | "payload": { |
| 26 | "definition": [ |
| 27 | "autonomous agent", |
| 28 | { |
| 29 | "base_aa": "{"JH3LOA27OOP443BAGJYBHONKCK6NPLAB"}", |
| 30 | "params": { |
| 31 | "asset_id": "{$asset}", |
| 32 | "amount": "{$amount}", |
| 33 | "destination_address": "{$destination}", |
| 34 | "deadline": "{$deadline}", |
| 35 | "hash_of_secret": "{$hash}" |
| 36 | } |
| 37 | } |
| 38 | ] |
| 39 | } |
| 40 | }, |
| 41 | { |
| 42 | "app": "payment", |
| 43 | "payload": { |
| 44 | "asset": "base", |
| 45 | "outputs": [ |
| 46 | { |
| 47 | "address": "{trigger.address}", |
| 48 | "amount": "{balance[base]}" |
| 49 | } |
| 50 | ] |
| 51 | } |
| 52 | }, |
| 53 | { |
| 54 | "app": "state", |
| 55 | "state": "{ |
| 56 | response['message'] = "A lock box as been created for '"||$destination||"'by the following unit: "||response_unit; |
| 57 | }" |
| 58 | } |
| 59 | ] |
| 60 | }, |
| 61 | { |
| 62 | "messages": [ |
| 63 | { |
| 64 | "app": "state", |
| 65 | "state": "{ |
| 66 | bounce("I need: 'amount', 'destination_address' and 'hash_of_secret' and optionally 'asset_id' and 'duration_in_hours'."); |
| 67 | }" |
| 68 | } |
| 69 | ] |
| 70 | } |
| 71 | ] |
| 72 | } |
| 73 | } |
| 74 | ] |