[
"autonomous agent",
{
"bounce_fees": {
"base": 10000
},
"doc_url": "https://ipfs.io/ipfs/QmTUdzDj3CAekEf17Gvkq1wCb9RqSX2HQMPmZyqshC5XLj?filename={{aa_address}}.json",
"init": "{\r
$GovernanceAddress = 'R24O63ZV5OZ2KEMRRIABIPKDDBAB2OYB'; // controled by the fundraiser, used to finish the funding period\r
$FundingAddress = 'ON4GW3KQXSBMWRZVXEXKWGQLGUBKBYBQ'; // this address receives the Milestone payments\r
$OracleAddress = 'TFLUCOKCYTC6EL5OTFB2DITDZNAW677J';\r
$Price = 1e6; // bytes per token\r
$Target = 1e9; // target can be exceeded but is refundable if less raised by expiry timestamp\r
$ExpiryTimestamp = 1704067199; // Jan 1, 2024\r
$Milestone1 = 10; // in %\r
$Milestone2 = 30;\r
$Milestone3 = 40;\r
$Milestone4 = 20;\r
$Asset = var['Asset'];\r
$Finished = var['Finished'];\r
$IsActive = ($Asset AND $Price AND !$Finished);\r
}",
"messages": {
"cases": [
{
"if": "{trigger.data.define AND trigger.address == $GovernanceAddress AND !$Asset}",
"messages": [
{
"app": "asset",
"payload": {
"is_private": false,
"is_transferrable": true,
"auto_destroy": false,
"fixed_denominations": false,
"issued_by_definer_only": true,
"cosigned_by_definer": false,
"spender_attested": false
}
},
{
"app": "state",
"state": "{\r
var['Asset'] = response_unit;\r
response['Asset'] = response_unit;\r
}"
}
]
},
{
"if": "{ trigger.output[[asset=base]] >= $Price AND $IsActive }",
"init": "{\r
$amount = round(trigger.output[[asset=base]] / $Price);\r
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "{$Asset}",
"outputs": [
{
"address": "{trigger.address}",
"amount": "{$amount}"
}
]
}
}
]
},
{
"if": "{ (trigger.data.finish AND trigger.address == $GovernanceAddress) OR timestamp > $ExpiryTimestamp }",
"messages": [
{
"app": "state",
"state": "{\r
var['Finished'] = 1;\r
var['Total'] = balance[base];\r
response['Total'] = balance[base];\r
}"
}
]
},
{
"if": "{trigger.data.milestone AND trigger.address == $OracleAddress AND $Finished AND var['Total'] >= $Target}",
"init": "{\r
$share = ${'Milestone' || trigger.data.milestone} / 100;\r
if (!$share)\r
bounce('no such Milestone');\r
if (var['Milestone' || trigger.data.milestone || '_released'])\r
bounce('Milestone ' || trigger.data.milestone || ' already released');\r
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{$FundingAddress}",
"amount": "{round(var['Total'] * $share)}"
}
]
}
},
{
"app": "state",
"state": "{\r
var['Milestone' || trigger.data.milestone || '_released'] = 1;\r
response['released'] = 1;\r
}"
}
]
},
{
"if": "{$Asset AND trigger.output[[asset=$Asset]] > 0 AND $Finished AND var['Total'] < $Target}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{trigger.address}",
"amount": "{ round(trigger.output[[asset=$Asset]] * $Price) }"
}
]
}
}
]
},
{
"messages": [
{
"app": "state",
"state": "{\r
response['contribution_value'] \r
= $IsActive AND trigger.output[[asset=base]] < $Price \r
? 'Contribution below minimum of '|| $Price \r
: !$IsActive \r
? 'Funding not active.' \r
: trigger.output[[asset=base]];\r
}"
}
]
}
]
}
}
]