| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $puk = trigger.data.puk1||trigger.data.puk2; |
| 6 | $asset = trigger.output[[asset=base]].asset; |
| 7 | $key = $puk||'_'||$asset; |
| 8 | }", |
| 9 | "messages": { |
| 10 | "cases": [ |
| 11 | { |
| 12 | "if": "{(trigger.data.puk1) AND (trigger.data.puk2) AND (!trigger.data.s) AND (!trigger.data.ad)}", |
| 13 | "messages": [ |
| 14 | { |
| 15 | "app": "state", |
| 16 | "state": "{ |
| 17 | var[$key] += trigger.output[[asset=base]]; |
| 18 | response['message'] = var[$key]||' '||$asset||' are safe under the puk '||$puk; |
| 19 | }" |
| 20 | } |
| 21 | ] |
| 22 | }, |
| 23 | { |
| 24 | "if": "{(trigger.data.puk1) AND (trigger.data.puk2) AND (trigger.data.s1) AND (trigger.data.s2) AND (trigger.data.ad)}", |
| 25 | "init": "{ |
| 26 | $asset_withdrawn = trigger.data.asset otherwise $asset; |
| 27 | if (!var[$key]) bounce ("puk doesn\'t exists with asset "||$asset); |
| 28 | if (!is_valid_sig(trigger.data.ad, "-----BEGIN PUBLIC KEY-----"||$puk||"-----END PUBLIC KEY-----", trigger.data.s1||trigger.data.s2)) bounce ("Wrong signature!"); |
| 29 | }", |
| 30 | "messages": [ |
| 31 | { |
| 32 | "app": "payment", |
| 33 | "payload": { |
| 34 | "asset": "{$asset}", |
| 35 | "outputs": [ |
| 36 | { |
| 37 | "address": "{trigger.data.ad}", |
| 38 | "amount": "{var[$key]}" |
| 39 | } |
| 40 | ] |
| 41 | } |
| 42 | }, |
| 43 | { |
| 44 | "app": "state", |
| 45 | "state": "{ |
| 46 | response['message'] = var[$key]||' sent to ' || trigger.data.ad; |
| 47 | var[$key] = false; |
| 48 | }" |
| 49 | } |
| 50 | ] |
| 51 | }, |
| 52 | { |
| 53 | "messages": [ |
| 54 | { |
| 55 | "app": "state", |
| 56 | "state": "{ |
| 57 | bounce ("Set a 'puk1' and 'puk2' field to <the 2 half of the public key, for which you have the related private key> to safely store funds. To withdraw later, set the same 'puk', as well as a 'ad' field to <the Obyte adresse where you want to receive the funds> and a 's1' and 's2' field to <the 2 half signature of a message containing the address 'a'>."); |
| 58 | }" |
| 59 | } |
| 60 | ] |
| 61 | } |
| 62 | ] |
| 63 | } |
| 64 | } |
| 65 | ] |