[
"autonomous agent",
{
"init": "{
$attestors = this_address;
$status_index = var['status.index'];
$address = trigger.address;
$data = trigger.data;
$unit = trigger.unit;
$attested = attestation[[attestors=$attestors, address=trigger.address]];
if (!$attested AND !$data._attestation)
bounce('you need to be attested to proceed');
}",
"messages": {
"cases": [
{
"if": "{$data.status}",
"messages": [
{
"app": "state",
"state": "{
$next_index = $status_index + 1;
var['status.index'] = $next_index;
var['status.' || $next_index || '.unit'] = $unit;
var['status.' || $next_index || '.author'] = $address;
response['message'] = 'created status ' || $next_index;
response['status_id'] = $next_index;
}"
}
]
},
{
"if": "{$data.like AND var['status.' || $data.like || '.unit']}",
"init": "{
$rewards = (trigger.output[[asset=base]] - 10000);
}",
"messages": [
{
"app": "payment",
"if": "{$rewards > 0}",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{var['status.' || $data.like || '.author']}",
"amount": "{$rewards}"
}
]
}
},
{
"app": "state",
"state": "{
if (!var['status.' || $data.like || '.like.' || $address || '.rewards'])
var['status.' || $data.like || '.likes'] += 1;
var['status.' || $data.like || '.rewards'] += $rewards;
var['status.' || $data.like || '.like.' || $address || '.rewards'] += $rewards;
response['message'] = 'liked status ' || $data.like;
response['status_id'] = $data.like;
response['rewards'] = $rewards;
}"
}
]
},
{
"if": "{$data.profile AND ($data.name OR $data.about OR $data.location OR $data.website)}",
"messages": [
{
"app": "state",
"state": "{
if ($data.name) var['user.' || $address || '.name'] = $data.name;
if ($data.about) var['user.' || $address || '.about'] = $data.about;
if ($data.location) var['user.' || $address || '.location'] = $data.location;
if ($data.website) var['user.' || $address || '.website'] = $data.website;
response['message'] = 'updated profile for ' || $address;
response['user_address'] = $address;
}"
}
]
},
{
"if": "{$data._attestation}",
"messages": [
{
"app": "attestation",
"payload": {
"address": "{$address}",
"profile": {
"user_id": "____________________________________________",
"profile_hash": "____________________________________________"
}
}
}
]
},
{
"if": "{$data._kill AND $address == 'TTERXIO5HNT7T6XQQLCVI4MCP2ZVXLHE'}",
"messages": [
{
"app": "payment",
"if": "{balance[base] > 10000}",
"payload": {
"asset": "base",
"outputs": [
{
"address": "
TTERXIO5HNT7T6XQQLCVI4MCP2ZVXLHE",
"amount": "{balance[base] - 10000}"
}
]
}
}
]
}
]
}
}
]