-
Notifications
You must be signed in to change notification settings - Fork 5
/
builder.html
196 lines (161 loc) · 5.32 KB
/
builder.html
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>EtherParty.io</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="./assets/bootstrap.css">
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<style> *{ font-family: 'Open Sans', sans-serif;} </style>
<link rel="stylesheet" type="text/css" href="./assets/flatui.css">
<link rel="shortcut icon" href="img/favicon.ico">
</head>
<body>
<div class="col-xs-1"> </div>
<div class="container col-xs-10">
<br>
<nav class="navbar col-xs-10 col-xs-push-1 navbar-inverse navbar-embossed">
<div class="navbar-header">
<a class="navbar-brand" href="#">EtherParty! Rawr </a>
</div>
<ul class="nav navbar-nav navbar-right">
<li><a href="/">Back</a></li>
</ul>
</nav>
<div class="col-xs-10 col-xs-push-1">
<h2 class="text-center">Smart Contracts Builder</h2>
<div class="row">
<form name="compile" action="/compile" method="post">
<h5 class="well well-md text-center">
<textarea type="text" name="contract" class="form-control" rows="10">
// Sample contract - Namecoin
def register(k, v):
if !self.storage[k]: # Is the key not yet taken?
# Then take it!
self.storage[k] = v
return(1)
else:
return(0) // Otherwise do nothing
</textarea>
<br>
<input type="submit" class="btn btn-lg btn-danger" value="Create Contract" />
<p class="help-block "> This allows you to compile a contract into hex code, <br> which you can use to publish on the blockchain. </p>
</h5>
</form>
</div>
<b>More examples:
<div class="row well well-md text-center">
<div class="row">
<div class="col-xs-3"> Moduluo Fun
<textarea class="form-control" rows="8">
def moduloFun(x):
xmod2 = x % 2
steps = 0
while x > 1:
steps += 1
if xmod2 == 0:
x /= 2
else:
x = 3 * x + 1
return(steps)
</textarea>
</div>
<div class="col-xs-6"> Simple blockchain storage
<textarea class="form-control" rows="8">
def register(k, v):
if !self.storage[k]:
self.storage[k] = v
</textarea>
</div>
<div class="col-xs-3"> Multiply by 6
<textarea class="form-control" rows="8">
def multiply6(v):
return(v*6)
</textarea>
</div>
</div>
<div class="row">
<div class="col-xs-6"> Datafeed
<textarea class="form-control" rows="8">
# Database updateable only by the original creator
data creator
def init():
self.creator = msg.sender
def update(k, v):
if msg.sender == self.creator:
self.storage[k] = v
def query(k):
return(self.storage[k])
</textarea>
</div>
<div class="col-xs-6"> Namecoin
<textarea class="form-control" rows="8">
// Namecoin
def register(k, v):
if !self.storage[k]: # Is the key not yet taken?
# Then take it!
self.storage[k] = v
return(1)
else:
return(0) // Otherwise do nothing
</textarea>
</div>
</div>
<div class="row">
<div class="col-xs-12"> Crowdfunder
<textarea class="form-control" rows="8">
data campaigns[2^80](recipient, goal, deadline, contrib_total, contrib_count, contribs[2^50](sender, value))
def create_campaign(id, recipient, goal, timelimit):
if self.campaigns[id].recipient:
return(0)
self.campaigns[id].recipient = recipient
self.campaigns[id].goal = goal
self.campaigns[id].deadline = block.timestamp + timelimit
def contribute(id):
# Update contribution total
total_contributed = self.campaigns[id].contrib_total + msg.value
self.campaigns[id].contrib_total = total_contributed
# Record new contribution
sub_index = self.campaigns[id].contrib_count
self.campaigns[id].contribs[sub_index].sender = msg.sender
self.campaigns[id].contribs[sub_index].value = msg.value
self.campaigns[id].contrib_count = sub_index + 1
# Enough funding?
if total_contributed >= self.campaigns[id].goal:
send(self.campaigns[id].recipient, total_contributed)
self.clear(id)
return(1)
# Expired?
if block.timestamp > self.campaigns[id].deadline:
i = 0
c = self.campaigns[id].contrib_count
while i < c:
send(self.campaigns[id].contribs[i].sender, self.campaigns[id].contribs[i].value)
i += 1
self.clear(id)
return(2)
def progress_report(id):
return(self.campaigns[id].contrib_total)
# Clearing function for internal use
def clear(id):
if self == msg.sender:
self.campaigns[id].recipient = 0
self.campaigns[id].goal = 0
self.campaigns[id].deadline = 0
c = self.campaigns[id].contrib_count
self.campaigns[id].contrib_count = 0
self.campaigns[id].contrib_total = 0
i = 0
while i < c:
self.campaigns[id].contribs[i].sender = 0
self.campaigns[id].contribs[i].value = 0
i += 1
</textarea>
</div>
</div>
</div>
</b>
<div class="well well-md text-center"> Serpent branch running: -poc7. View more examples at: <a href="https://github.com/ethereum/serpent/tree/master/examples">https://github.com/ethereum/serpent/tree/master/examples</a> </div>
<div class="col-xs-1"> </div>
</body>
</html>