6. 64 TIMES AS GOOD AS ITS NOT
( according to Google – Nov 2013 )
7. WHO AM I TO TELL YOU…?
Mark Smalley – http://twitter.com/m_smalley
R1 DOT MY Sdn Bhd – http://r1.my
Been Living in Malaysia for 16 Years
Developing Web-Applications for 15 Years
MongoDB Master / NoSQL Specialist
Passion for Community Management
Family Involved with Equity Fund Management
8. WE ALREADY HAVE CHOICE – WE EVEN HAVE PAYPAL
• Square, Stripe, V.me, Simple, etc …
• Only available to developers in States / Europe
• Local alternatives are complicated, costly & useless
• No options for instant starts …
• No options for anonymity or the billions of us unbanked
• In Malaysia we only have PayPal and iPay88
9. BITCOIN THE TECHNOLOGY STACK
• Uses LevelDB to access (via JSON) a globally distributed
public ledger of all transactions
• Send and receive payments instantly and directly via
JSON-RPC calls from any server-side language …
• Existing wrappers, frameworks, documentation, libraries
and support for PHP, Ruby, NodeJS
• Still in Beta (0.8) with Market Cap of US$12.8 Billion (Nov 2013)
• Version 0.9 to bring payment requests and receipts!
10. THE POWER OF DISTRIBUTED LEDGERS
• Removes central point of control (and failure)
– For developers this means an ALWAYS on API
• Can be used for things other than transactions
– For developers this means timestamps and cookies
• Provides a public record and optional anonymity
– For developers this means instant sign-up without verification
11. LET’S BUILD SOMETHING – LOGIN WITHOUT EMAIL
Before we begin, let’s ask why do such a crazy thing…?
• We do not need to manage our own database!
• We can integrate sign-up and payment as one process
• We do not force our users to provide their identity
• Nobody needs to sign-up or apply for accounts
• We can do business globally with anyone who has internet
12. JUMPING INTO CODE :: TABLE OF CONTENTS
https://github.com/msmalley/BCE/tree/master/php-login
// Include BTC login class
$login = new mongobase_btc_login();
// Get user information
$user = $login->user();
// Check if user is logged-in or not...?
$logged_in = $login->logged_in($user['uid']);
// Create and display relevant HTML
$html = $login->html($logged_in, $user['address']);
echo $html;
13. PART ONE – GET USER INFO
$user = $login->user();
// Check if got existing UID cookie
if(isset($_COOKIE[$cookie_name]))
{
$uid = $_COOKIE[$cookie_name];
// Get existing BTC address
$addresses = $this::$btc->query(array(
'function‘ => 'getaddressesbyaccount',
'options‘ => $cookie_name.'_'.$uid
));
$address = $addresses[0];
}
14. PART ONE – GET USER INFO (continued)
$user = $login->user();
// Else create a new UID cookie
}else{
// Gather server settings
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$user_time = $_SERVER['REQUEST_TIME'];
// Generate unique ID
$uid = hash('sha256',$user_salt.$user_agent.$user_time);
// Set UID cookie
setcookie($cookie_name, $uid, time() + $cookie_life);
// Create new BTC address
$address = $this::$btc->query(array(
'function‘ => 'getnewaddress',
'options‘ => $cookie_name.'_'.$uid
));
}
15. PART TWO – CHECK IF LOGGED-IN
$logged_in = $login->logged_in($user['uid']);
// Not by default
$logged_in = false;
// Check if got balance
$uid_balance = $this::$btc->query(array(
'function’ => 'getbalance',
'options’ => $cookie_name.'_'.$uid
));
// Check if logged-in
$details = $this->timed_cookies();
$logged_in = $details['logged_in'];
if(!$logged_in && $uid_balance > 0)
{
// Not logged-in but got transactions
$logged_in = $this->set_cookies();
}
return $logged_in;