| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $nom_AA = 'Registre'; |
| 6 | $versio = '01'; |
| 7 | |
| 8 | |
| 9 | $_Portal_original = trigger.address; |
| 10 | |
| 11 | $_Portal_actual = |
| 12 | data_feed[[ oracles = this_address, feed_name = 'portal_actual', ifnone = false ]] |
| 13 | otherwise $_Portal_original; |
| 14 | |
| 15 | if ( $_Portal_actual != trigger.address ) |
| 16 | { bounce ( 'Portal no reconegut' ); } |
| 17 | |
| 18 | $args = trigger.data; |
| 19 | |
| 20 | $qt_retorn = |
| 21 | balance[ base ] > 20000 ? |
| 22 | balance[ base ] - 20000 : |
| 23 | 0; |
| 24 | }", |
| 25 | "messages": [ |
| 26 | { |
| 27 | "app": "data_feed", |
| 28 | "payload": "{ $args }" |
| 29 | }, |
| 30 | { |
| 31 | "if": "{ $qt_retorn > 100000000 }", |
| 32 | "app": "payment", |
| 33 | "payload": { |
| 34 | "asset": "base", |
| 35 | "outputs": [ |
| 36 | { |
| 37 | "address": "{ $_Portal_actual }", |
| 38 | "amount": "{ $qt_retorn }" |
| 39 | } |
| 40 | ] |
| 41 | } |
| 42 | }, |
| 43 | { |
| 44 | "app": "state", |
| 45 | "state": "{ |
| 46 | response[ 'Resultat' ] = 'Dades registrades'; |
| 47 | response[ 'Romanent Registre' ] = balance[ base ] || ' bytes'; |
| 48 | }" |
| 49 | } |
| 50 | ] |
| 51 | } |
| 52 | ] |