| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | /* |
| 6 | ========================================== |
| 7 | OBYTE STACK GAME from Whistling Frogs |
| 8 | ========================================== |
| 9 | Written by Crypto Girl on 21 Sep 2019 |
| 10 | ========================================== |
| 11 | Test version: 0.1 |
| 12 | ========================================== |
| 13 | Can be used with OBYTE STACK GAME BOT v0.1 |
| 14 | =========================================== |
| 15 | |
| 16 | The object of the game is to win the Stack. |
| 17 | Users make bids. Min bid is 100,000 bytes. |
| 18 | 1st bid initiates the Stack. |
| 19 | Each subsequent bid restarts the 5 min timer. |
| 20 | If more than 5 min has passed since the last bid, |
| 21 | the stack is paid out to the previous bidder and |
| 22 | the new stack is initiated with the latest bid. |
| 23 | A commission of 10,000 bytes is charged on each bid. |
| 24 | */ |
| 25 | $now = timestamp ; |
| 26 | $min_bid_amnt = 100000; |
| 27 | $bid_amnt = trigger.output[[asset=base]]; |
| 28 | $bid_status = ($bid_amnt >= $min_bid_amnt) otherwise false; |
| 29 | |
| 30 | if ($bid_status == false) |
| 31 | bounce('Your bid is too small.'); |
| 32 | |
| 33 | $stack_status = var['stack_status'] otherwise 'not started'; |
| 34 | $duration = 300; |
| 35 | $fee = 10000; |
| 36 | $seed_amnt = 10000; |
| 37 | $commission_address = 'B7KF2F5AP6BZLXOE2EGHH6BKZWVNIKWF'; |
| 38 | $commission_payout_threshold = 10000; |
| 39 | }", |
| 40 | "messages": [ |
| 41 | { |
| 42 | "app": "payment", |
| 43 | "if": "{$bid_status == true AND $stack_status == 'running' AND $now > var['period_end']}", |
| 44 | "payload": { |
| 45 | "asset": "base", |
| 46 | "outputs": [ |
| 47 | { |
| 48 | "address": "{ var['leader'] }", |
| 49 | "amount": "{ var['stack_amnt'] }" |
| 50 | } |
| 51 | ] |
| 52 | } |
| 53 | }, |
| 54 | { |
| 55 | "app": "payment", |
| 56 | "if": "{ var['commission'] >= $commission_payout_threshold }", |
| 57 | "payload": { |
| 58 | "asset": "base", |
| 59 | "outputs": [ |
| 60 | { |
| 61 | "address": "{ $commission_address }", |
| 62 | "amount": "{ var['commission'] }" |
| 63 | } |
| 64 | ] |
| 65 | } |
| 66 | }, |
| 67 | { |
| 68 | "app": "state", |
| 69 | "state": "{ |
| 70 | |
| 71 | if ($bid_status AND $stack_status == 'not started') { |
| 72 | var['stack_amnt'] = $bid_amnt - $fee; |
| 73 | var['stack_status'] = '1st bid made'; |
| 74 | var['leader'] = trigger.initial_address; |
| 75 | } |
| 76 | |
| 77 | if ($bid_status == true AND $stack_status == '1st bid made') { |
| 78 | var['stack_amnt'] += ($bid_amnt - $fee); |
| 79 | var['stack_status'] = 'running'; |
| 80 | var['leader'] = trigger.initial_address; |
| 81 | var['period_end'] = timestamp + $duration; |
| 82 | } |
| 83 | |
| 84 | if ($bid_status == true AND $stack_status == 'running' AND $now <= var['period_end']) { |
| 85 | var['stack_amnt'] += ($bid_amnt - $fee); |
| 86 | var['period_end'] = timestamp + $duration; |
| 87 | var['leader'] = trigger.initial_address; |
| 88 | } |
| 89 | |
| 90 | if ($bid_status == true AND $stack_status == 'running' AND $now > var['period_end']) { |
| 91 | var['commission'] = balance[base] - $seed_amnt; |
| 92 | var['stack_amnt'] = $bid_amnt - $fee; |
| 93 | var['stack_status'] = '1st bid made'; |
| 94 | var['leader'] = trigger.initial_address; |
| 95 | } |
| 96 | }" |
| 97 | } |
| 98 | ] |
| 99 | } |
| 100 | ] |