BPHIPP3JIGZYYTNW7B3Y6M3FDTFQ5KOF
[
"autonomous agent",
{
"init": "{
// Define your initial parameters
$asset_id = "oK5DtUNh4n9oKbU91m6R26JyJIyqPh3483Qlr62wkPo="; // The ID of the asset you are selling
$exchange_rate = 1000000; // Exchange rate: 1000000 bytes = 1 units of the asset
$min_payment = 1000000; // Minimum payment in bytes for a transaction (1000000 bytes)
}",
"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