forked from s6ruby/programming-crypto-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathponzi_simple.rb
33 lines (24 loc) · 832 Bytes
/
ponzi_simple.rb
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
# encoding: utf-8
##
# a simple ponzy (scheme) contract
# last investor (or sucker) HODLing the bag
#
# to run type:
# $ ruby ./run_ponzi_simple.rb
class SimplePonzi < Contract
def initialize
@current_investor = msg.sender # type address - (hex) string starts with 0x
@current_investment = 0 # type uint
end
def receive ## @payable default function
# note: new investments must be 10% greater than current
minimum_investment = @current_investment * 11/10
assert( msg.value > minimum_investment )
# record new investor
previous_investor = @current_investor
@current_investor = msg.sender
@current_investment = msg.value
# pay out previous investor
previous_investor.send( msg.value )
end
end # class SimplPonzi