-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_oracle.teal
More file actions
74 lines (63 loc) · 1.5 KB
/
basic_oracle.teal
File metadata and controls
74 lines (63 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Oracle Example
//
// Author: Gokul Alex
//
//
// It is a way to illustrate a bet between 2 addresses. One says that '0' will happen (team A wins)
// while the other says '1' will happen (team B wins)
//
//
// Program flow:
// If the oracle signs a message with '0'
// the algos go to TMPL_ADDRA
// If the oracle signs a '1' the algos go to TMPL_ADDRB
//
// Parameters:
// - TMPL_ADDRA: Address beting for Team A. BKJX2U52PKL27XS42VO4SJW5BBFBYDCN7NYAW6BUEKF7EBYX5XV5CKAPT4
// - TMPL_ADDRB: Address beting for Team B. 36WZVNA6YA77V2MGGLJBT2YQG3RQVX6UWJ3P6E7FWNAV4IGMK3ZVVNBLVQ
// - TMPL_ADDR_ORACLE: Oracle Address. SVDICE2QVOMQPYCYRJGRBOZPLYGF5DQOK3FFHL26FUOBQLWBKDH3EAQS3U
// - TMPL_FEE: maximum fee used by the limit order transaction. 10000
txn TypeEnum
int 1 // Payment (either Algos-out in trade or Algos redeemed at timeout)
==
global GroupSize
int 1
==
&&
// if arg 0 == 0 then send to TMPL_ADDRA
arg 0
byte base64 MA==
==
txn CloseRemainderTo
addr BKJX2U52PKL27XS42VO4SJW5BBFBYDCN7NYAW6BUEKF7EBYX5XV5CKAPT4
==
&&
txn Receiver
addr BKJX2U52PKL27XS42VO4SJW5BBFBYDCN7NYAW6BUEKF7EBYX5XV5CKAPT4
==
&&
// if arg 0 == 1 then send to TMPL_ADDRB
arg 0
byte base64 MQ==
==
txn CloseRemainderTo
addr 36WZVNA6YA77V2MGGLJBT2YQG3RQVX6UWJ3P6E7FWNAV4IGMK3ZVVNBLVQ
==
&&
txn Receiver
addr 36WZVNA6YA77V2MGGLJBT2YQG3RQVX6UWJ3P6E7FWNAV4IGMK3ZVVNBLVQ
==
&&
||
// global verifications
&&
txn Fee
int 1000
<=
&&
// verify oracle signature
arg 0
arg 1
addr SVDICE2QVOMQPYCYRJGRBOZPLYGF5DQOK3FFHL26FUOBQLWBKDH3EAQS3U
ed25519verify
&&