CTO of Starbase
Yu Yamanaka
July 18, 2017, at Yahoo! LODGE
Full-stack Developer / Entrepreneur / Crypto Investor
Programmer
& DevOps Engineer
2007
2017
CTO
Co-founder & CTO
Full-stack Engineer
& Agile PM
Infrastructure Architect
Twitter: https://twitter.com/yurelx
Blog: http://staycreative.jp/
Kickstarter by Crypto-Currency
Make raising funds by "Token" a common way of finance.
= Amout x Price
the financial crisis
-42%
(2012~2013) +29%
Increased 200% for a year!
Increased 1300% for a year!!
They were just listed in last May, June
$20M
$13M
$12M
Traditional IPO = Listing of Stock
Initial Coin Offering = Listing of Cryptocurrency on private exchange(s)
You can see the source code here
They were just listed last spring
World-Wide Distributed
Application Platform
A program executes the terms
of a contract
A fuel to run DApps on Ethereum /
A virtual currency like Bitcoin
"BIG" IDEA
(fundraiser)
ICO
Market Trade
Build the product with the raised funds
Crowdsale
Make smart contracts, whitepaper, website, prototype, etc...
Find team members, advisers, angel investors
Crowdfunding
by Crypto-Currency
Token
Crypto-Currency
1 contract ERC20 {
2 function totalSupply() constant returns (uint totalSupply);
3 function balanceOf(address _owner) constant returns (uint balance);
4 function transfer(address _to, uint _value) returns (bool success);
5 function transferFrom(address _from, address _to, uint _value) returns (bool success);
6 function approve(address _spender, uint _value) returns (bool success);
7 function allowance(address _owner, address _spender) constant returns (uint remaining);
8 event Transfer(address indexed _from, address indexed _to, uint _value);
9 event Approval(address indexed _owner, address indexed _spender, uint _value);
10 }
ERC20 token standard makes DApps, wallets, and exchanges easier to handle tokens issued on Ethereum.
Are you ready?
Let's see the code!!
You can see the source code here
pragma solidity ^0.4.10;
/* taking ideas from FirstBlood token */
contract SafeMath {
/* function assert(bool assertion) internal { */
/* if (!assertion) { */
/* throw; */
/* } */
/* } // assert no longer needed once solidity is on 0.4.10 */
function safeAdd(uint256 x, uint256 y) internal returns(uint256) {
uint256 z = x + y;
assert((z >= x) && (z >= y));
return z;
}
A programming language to write smart contract
contract Token {
uint256 public totalSupply;
function balanceOf(address _owner) constant returns (uint256 balance);
function transfer(address _to, uint256 _value) returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
function approve(address _spender, uint256 _value) returns (bool success);
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
/* ERC 20 token */
contract StandardToken is Token {
function transfer(address _to, uint256 _value) returns (bool success) {
...
}
Abstract Contract: a contract lacks implementations
An ERC20 compatible token needs to implement the ERC20 interfaces
Event: a kind of log. Useful for event driven processing too. (e.g. notify someone when a transfer made)
function transfer(address _to, uint256 _value) returns (bool success) {
if (balances[msg.sender] >= _value && _value > 0) {
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
} else {
return false;
}
}
...
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
...
mapping (address => uint256) balances;
Executable function, a function without `constant` qualifier, can write data on a smart contract but requires "gas"(Ether) to run
Callable function, a function with `constant` qualifier, can read data from storages on a smart contract and it does not require "gas"(Ether) to run
Make an event
`mapping` is a kind of HashMap. This is a storage persisted on the contract
contract BAToken is StandardToken, SafeMath {
// metadata
string public constant name = "Basic Attention Token";
string public constant symbol = "BAT";
uint256 public constant decimals = 18;
string public version = "1.0";
// contracts
address public ethFundDeposit; // deposit address for ETH for Brave International
address public batFundDeposit; // deposit address for Brave International use and BAT User Fund
// crowdsale parameters
bool public isFinalized; // switched to true in operational state
uint256 public fundingStartBlock;
uint256 public fundingEndBlock;
uint256 public constant batFund = 500 * (10**6) * 10**decimals; // 500m BAT reserved for Brave Intl use
uint256 public constant tokenExchangeRate = 6400; // 6400 BAT tokens per 1 ETH
uint256 public constant tokenCreationCap = 1500 * (10**6) * 10**decimals;
uint256 public constant tokenCreationMin = 675 * (10**6) * 10**decimals;
Metadata are used by external services like Etherscan
Money Flow
Investors
This smart contract
Brave's fund
/// @dev Accepts ether and creates new BAT tokens.
function createTokens() payable external {
if (isFinalized) throw;
if (block.number < fundingStartBlock) throw;
if (block.number > fundingEndBlock) throw;
if (msg.value == 0) throw;
// check that we're not over totals
uint256 tokens = safeMult(msg.value, tokenExchangeRate);
uint256 checkedSupply = safeAdd(totalSupply, tokens);
// return money if something goes wrong
if (tokenCreationCap < checkedSupply) throw; // odd fractions won't be found
totalSupply = checkedSupply;
balances[msg.sender] += tokens; // safeAdd not needed; bad semantics to use here
CreateBAT(msg.sender, tokens); // logs token creation
}
`payable`: accepts Ether
`external`: executable or callable from outside of the contract
Money Flow
Investors
This smart contract
Brave's fund
Issue new BAT tokens and allocate them to the sender(investor)'s address
/// @dev Ends the funding period and sends the ETH home
function finalize() external {
if (isFinalized) throw;
if (msg.sender != ethFundDeposit) throw; // locks finalize to the ultimate ETH owner
if(totalSupply < tokenCreationMin) throw; // have to sell minimum to move to operational
if(block.number <= fundingEndBlock && totalSupply != tokenCreationCap) throw;
// move to operational
isFinalized = true;
if(!ethFundDeposit.send(this.balance)) throw; // send the eth to Brave International
}
/// @dev Allows contributors to recover their ether in the case of a failed funding campaign.
function refund() external {
...
}
Money Flow
Investors
This smart contract
Brave's fund
Ethereum Mainnet
Geth (Ethreum Node)
Smart Contract
(run on your machine)
Build & Deploy
Sync to other nodes
Ethereum Mainnet
Geth (Ethreum Node)
Off-chain applications
write data
read data
sync data
by Web3 lib
ICO =
Listing of Cryptocurrency on private exchange(s)
Crowdfunding
by Crypto-Currency before ICO
Technologies support Crowdsale/ICO
Ethereum, Ether, Smart Contract, ERC20 Token Standard
Tools and libs to write/deploy smart contract
Solidity, OpenZeppelin, Truffle, Web3, Geth
BAT's Smart Contract
Starbase is a platform to support innovators to do a Crowdsale and ICO
(Understand the mechanism, then invest smart)
CTO of Starbase
Yu Yamanaka
July 18, 2017, at Yahoo! LODGE