ZL3SEKDQ4APV2PW6YIXADFISJ3I5LZJD
[
"autonomous agent",
{
"init": "{
// Define your initial parameters
$asset_id = "WWW"; // The ID of the asset you are selling
$exchange_rate = 1.00; // Exchange rate: 1 byte = 1 units of the asset
$min_payment = 1; // Minimum payment in bytes for a transaction (1 byte)
}",
"messages": {
"cases": [
{
"if": "{trigger.output[[asset=base]] >= $min_payment}",
"init": "{
$received_bytes = trigger.output[[asset=base]]; // Amount received in bytes
$asset_amount = floor($received_bytes * $exchange_rate); // Convert bytes to asset units
response['message'] = 'Received ' || $received_bytes || ' bytes. Sending ' || $asset_amount || ' units of the asset.';
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "{$asset_id}",
"outputs": [
{
"address": "{trigger.address}",
"amount": "{$asset_amount}"
}
]
}
}
]
},
{
"if": "{trigger.output[[asset=base]] < $min_payment}",
"messages": [
{
"app": "state",
"state": "{ response['error'] = 'Minimum payment is ' || $min_payment || ' bytes.'; }"
}
]
}
]
}
}
]
Show transactions in assets:
No transactions found, it may be worth changing the filter
Unit ID
Date
From
Direction
To
Amount