Definition: [
"autonomous agent",
{
"init": "{
$processor = "HFNBIQTUNVMRM7PDP6NT2QRKLR62FOGR" ;
// Obot by [email protected]
// Get paid for doing computation on your computer, think Lambda for Obyte
// The perfect function is one that takes little input data or a link to a big data set, then do complex or private computation
// the processor runs headless wallet which listens for jobs from this AA
// usage:
// 1) function caller calls this AA with { "function" : "<function name>" , "args" : '<value or json>' } and processing fee
// 2) processor computes and send to this AA { "job" : <job number> , "result" : <index> }
// 3) the result gets sent back to caller and processor gets the processing fee
// 4) result verification is up to the function caller, perhaps using simple technique like compare results from multiple Obots
// setup:
// set $processor to address which can add new function and take payment out
// processor then need to have a Obot headless wallet listening to this AA's response
// processor add function with { "function" : "<function name>" , "price" : 100,000 }
// example use:
// caller sends { "function" : "insertsorted" , "args" : 50 } with 100000 bytes
// and gets response { "job" : 1 , "function" : "insertsorted" , "args" : 50 }
// wait for result { "job" : 1 , "result" : 2 }
$function = trigger.data.function ;
}",
"messages": {
"cases": [
{
"if": "{ trigger.address == $processor AND $function AND trigger.data.price }",
"messages": [
{
"app": "state",
"state": "{
// ADD FUNCTION
if( trigger.data.function >= 0 ) bounce( "function cannot be positive integer, because job are stored as positive integer" ) ;
var[ trigger.data.function ] = trigger.data.price ;
}"
}
]
},
{
"if": "{ var[ $function ] AND trigger.output[[asset=base]] >= var[ $function ] }",
"messages": [
{
"app": "state",
"state": "{
// START JOB
var[ "job" ] += 1 ;
var[ var[ "job" ] ] = trigger.address ; // store caller to receive result later
// send job to listening Obot headless wallet
response[ "job" ] = var[ "job" ] ;
response[ "function" ] = $function ;
response[ "args" ] = trigger.data.args otherwise false ;
}"
}
]
}
]
}
}
]