Unit ID
c57jsSw/VuxcsLecQqpxzqljqx80NvXPtgN4KVz1FnA=
Received
02.12.2021 21:37:23
Confirmation delay (full node)
5 minutes 11 seconds
Confirmation delay (light node)
8 minutes 37 seconds
Messages
Definition
Definition: [ "autonomous agent", { "init": "{ $CT_ADDRESS = "ZIT3YPDTLGAO7MVO2ONNDMSEYS2VELX6"; $OWNER = params.issuer; $LICENSE_ASSET = var["licenseAsset"]; if ($LICENSE_ASSET){ $priceStr = data_feed[[oracles=$OWNER, feed_name=this_address, ifseveral="last", type="string"]]; $chunks = split($priceStr, " "); require(length($chunks) == 2, "Malformed data_feed. It should have only 2 items"); $PRICE = $chunks[0]; require(is_integer($PRICE), "Price must be an integer"); require($PRICE > 0, "Price must be positive"); require(is_valid_amount($PRICE), "Price must be a valid amount"); $PRICE_ASSET = $chunks[1]; require(asset[$PRICE_ASSET].exists, "Price asset does not exist"); } $method = trigger.data["method"]; $CUT = 0.03; if ($LICENSE_ASSET AND NOT $method) bounce("method field is mandatory"); }", "messages": { "cases": [ { "if": "{NOT $LICENSE_ASSET}", "messages": [ { "if": "{params.cap}", "app": "asset", "payload": { "is_private": false, "cap": "{params.cap OTHERWISE 0}", "is_transferrable": "{NOT NOT params.tradeable}", "auto_destroy": false, "fixed_denominations": false, "issued_by_definer_only": true, "cosigned_by_definer": false, "spender_attested": false } }, { "if": "{NOT params.cap}", "app": "asset", "payload": { "is_private": false, "is_transferrable": "{NOT NOT params.tradeable}", "auto_destroy": false, "fixed_denominations": false, "issued_by_definer_only": true, "cosigned_by_definer": false, "spender_attested": false } }, { "app": "state", "state": "{ var["licenseAsset"] = response_unit; }" } ] }, { "if": "{trigger.address == $OWNER AND $method == "payout"}", "messages": { "cases": [ { "if": "{$method == "payout"}", "messages": [ { "app": "payment", "payload": { "asset": "{trigger.data.asset OTHERWISE $PRICE_ASSET}", "outputs": [ { "address": "{$OWNER}" } ] } } ] } ] } }, { "if": "{$method == "buy"}", "init": "{ $copies = floor(trigger.output[[asset=$PRICE_ASSET]]/$PRICE, 0); require($copies > 0, "You cannot buy less than 1 license"); $hasReferral = (trigger.data["r"] AND is_valid_address(trigger.data["r"])); $cut = $hasReferral ? $CUT/2 : $CUT; $cutAmount = round(trigger.output[[asset=$PRICE_ASSET]] * $cut, 0); }", "messages": [ { "app": "payment", "payload": { "asset": "{$LICENSE_ASSET}", "outputs": [ { "address": "{trigger.data["to"] OTHERWISE trigger.initial_address}", "amount": "{$copies}" } ] } }, { "app": "payment", "payload": { "asset": "{$PRICE_ASSET}", "outputs": [ { "address": "{$CT_ADDRESS}", "amount": "{$cutAmount}" }, { "if": "{$hasReferral}", "address": "{trigger.data["r"]}", "amount": "{$cutAmount}" } ] } } ] } ] } } ]
Technical information
Fees:
3,254 bytes
(452 headers, 2802 payload)
Level:2500595
Witnessed level:2500585
Main chain index:2480736
Latest included mc index:2480735
Status:stable/confirmed/final