| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $processor = "HFNBIQTUNVMRM7PDP6NT2QRKLR62FOGR" ; |
| 6 | |
| 7 | // Obot by [email protected] |
| 8 | // Get paid for doing computation on your computer, think Lambda for Obyte |
| 9 | // The perfect function is one that takes little input data or a link to a big data set, then do complex or private computation |
| 10 | // the processor runs headless wallet which listens for jobs from this AA |
| 11 | // usage: |
| 12 | // 1) function caller calls this AA with { "function" : "<function name>" , "args" : '<value or json>' } and processing fee |
| 13 | // 2) processor computes and send to this AA { "job" : <job number> , "result" : <index> } |
| 14 | // 3) the result gets sent back to caller and processor gets the processing fee |
| 15 | // 4) result verification is up to the function caller, perhaps using simple technique like compare results from multiple Obots |
| 16 | // setup: |
| 17 | // set $processor to address which can add new function and take payment out |
| 18 | // processor then need to have a Obot headless wallet listening to this AA's response |
| 19 | // processor add function with { "function" : "<function name>" , "price" : 100,000 } |
| 20 | // example use: |
| 21 | // caller sends { "function" : "insertsorted" , "args" : 50 } with 100000 bytes |
| 22 | // and gets response { "job" : 1 , "function" : "insertsorted" , "args" : 50 } |
| 23 | // wait for result { "job" : 1 , "result" : 2 } |
| 24 | |
| 25 | $function = trigger.data.function ; |
| 26 | |
| 27 | }", |
| 28 | "messages": { |
| 29 | "cases": [ |
| 30 | { |
| 31 | "if": "{ trigger.address == $processor AND $function AND trigger.data.price }", |
| 32 | "messages": [ |
| 33 | { |
| 34 | "app": "state", |
| 35 | "state": "{ |
| 36 | // ADD FUNCTION |
| 37 | if( trigger.data.function >= 0 ) bounce( "function cannot be positive integer, because job are stored as positive integer" ) ; |
| 38 | var[ trigger.data.function ] = trigger.data.price ; |
| 39 | }" |
| 40 | } |
| 41 | ] |
| 42 | }, |
| 43 | { |
| 44 | "if": "{ var[ $function ] AND trigger.output[[asset=base]] >= var[ $function ] }", |
| 45 | "messages": [ |
| 46 | { |
| 47 | "app": "state", |
| 48 | "state": "{ |
| 49 | // START JOB |
| 50 | var[ "job" ] += 1 ; |
| 51 | var[ var[ "job" ] ] = trigger.address ; // store caller to receive result later |
| 52 | |
| 53 | // send job to listening Obot headless wallet |
| 54 | response[ "job" ] = var[ "job" ] ; |
| 55 | response[ "function" ] = $function ; |
| 56 | response[ "args" ] = trigger.data.args otherwise false ; |
| 57 | }" |
| 58 | } |
| 59 | ] |
| 60 | } |
| 61 | ] |
| 62 | } |
| 63 | } |
| 64 | ] |