Hello,
I've started a new (free online) step-by-step guide / booklet titled:
Programming Crypto Blockchain Contracts (with Ruby) Step-by-Step
Book / Guide. [1]
Let's Start with Ponzi & Pyramid Schemes. Run Your Own Lotteries,
Gambling Casinos and more on the Blockchain World Computer...
The first chapter about Ponzis & Pyramids is online with
ready-to-run contract scripts in ruby. Example:
···
##
# a simple ponzy (scheme) contract
# last investor (or sucker) HODLing the bag
#
# to run / test - use:
# $ ruby ./ponzi_simple.rb
require_relative './lib/universum'
class SimplePonzi < Contract
def initialize
@current_investor = '0x0000'
@current_investment = 0
end
def call
# note: new investments must be 10% greater than current
minimum_investment = @current_investment * 11/10
require( 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
###
# test contract
## setup test accounts with starter balance
Account[ '0xaaaa' ].balance = 1_000_000
Account[ '0xbbbb' ].balance = 1_200_000
Account[ '0xcccc' ].balance = 1_400_000
## (pp) pretty print all known accounts with balance
pp Uni.accounts
ponzi = SimplePonzi.new
Uni.send_transaction( from: '0xaaaa', to: ponzi, value: 1_000_000 )
pp ponzi
Uni.send_transaction( from: '0xbbbb', to: ponzi, value: 1_200_000 )
pp ponzi
Uni.send_transaction( from: '0xcccc', to: ponzi, value: 1_400_000 )
pp ponzi
## (pp) pretty print all known accounts with balance
pp Uni.accounts
Don't Miss the Investment of a Lifetime!
May the Brave be Rewared with Riches! Happy coding with ruby!
Cheers. Prost.
PS: Bonus points if you can point out how to "hack" the simple ponzi - that is,
how you can "invest" with a guaranteed pay out!
[1] https://github.com/openblockchains/programming-cryptocontracts