Learn Ethereum development
with the smart contract gathered
$35M in 30 secs
CTO of Starbase
Yu Yamanaka
July 18, 2017, at Yahoo! LODGE
What's the motivation to read this presentation?
- A new business idea with Ethereum and Smart Contract may come up
- You may debut in a Crowdsale/ICO as an investor or fundraiser
About me
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/
- 10 years of experiences in enterprise and web technologies
- Maintained large scale and rapid growing services (800 servers, 15M users, etc.)
- Dived into this Blockchain world in Oct. 2016
Starbase
"Skyrocket your idea"
Kickstarter by Crypto-Currency
Make raising funds by "Token" a common way of finance.
Starbase
Team
Market Cap
= Amout x Price
Market Cap of US stocks
the financial crisis
-42%
(2012~2013) +29%
Market Cap of Bitcoin
Increased 200% for a year!
Market Cap of Altcoins/Tokens
Increased 1300% for a year!!
Market Cap Ranking (Top 5)
Market Cap Ranking (~ 50)
They were just listed in last May, June
Even though they have no products,
Aragon
Bancor
(Kickstarter as a reference)
$20M
$13M
$12M
What is "ICO"?
Traditional IPO = Listing of Stock
Initial Coin Offering = Listing of Cryptocurrency on private exchange(s)
Today's
Main Topic
Learn Ethereum development
with the smart contract gathered
$35M in 30 secs
Market Cap Ranking (~ 50)
Raised $35M
in 30 secs
Basic Attention Token
Basic Attention Token
OKAY, BUT HOW THEY RASED?
They gathered the funds by a Smart Contract
You can see the source code here
3 steps to understand the mechanism
- Understand Ethereum & Smart Contract
- Technologies support ICO
- Learn with BAT's smart contract
1. Understand
Ethereum & Smart Contract
They were issued on Ethereum!
They were just listed last spring
Ethereum: the World Computer
Ethereum: the World Computer
World-Wide Distributed
Application Platform
- Working by miners like Bitcoin
- Everyone can use by paying Ether
- Connectable with traditional apps
- Infrastructure for Smart Contracts
Smart Contract
A program executes the terms
of a contract
- Define terms by programming
- Deploy the program on Ethereum
- A user or app calls a function of the program with Ether
- The program runs according to the terms
Ether
A fuel to run DApps on Ethereum /
A virtual currency like Bitcoin
- Ether(ETH) = Fuel of DApps = Fee
- Required to run a function on a smart contract
- Works as a "currency" like Bitcoin since it has a market price
2. Technologies support "ICO"
"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
ICO process (1~2years)
Crowdsale
Crowdfunding
by Crypto-Currency
- Raise funds from the world's investors in major cryptocurrencies (like BTC/ETH)
- The investors get certain tokens according to the investment
- The investors can sell the tokens once it is listed on an exchange
- Usually, it has a cap and period
Token
Token
Crypto-Currency
- Token is a Crypto-Currency
- Token has market cap, and it is transferable like Bitcoin
- Token holders have special rights
(e.g. revenue share)
ERC20: A standard for Ethereum Tokens
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!!
3. Learn with BAT's contract
BAT's smart contract
You can see the source code here
Just 175 lines!!
Solidity / SafeMath
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
- Library functions to do arithmetic operations "securely"
- Smart Contract cannot be modified once it has been deployed
- OpenZeppelin library provides several secure functions
Abstract Contract / Event / Inheritence
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
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
Constant
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
Create Tokens
/// @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
Finalize
/// @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
How to deploy Smart Contract on Ethereum
Ethereum Mainnet
Geth (Ethreum Node)
Smart Contract
(run on your machine)
Build & Deploy
Sync to other nodes
How to integrate with Ethereum
Ethereum Mainnet
Geth (Ethreum Node)
Off-chain applications
write data
read data
sync data
by Web3 lib
Conclusion
ICO =
Listing of Cryptocurrency on private exchange(s)
Crowdsale =
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
"Risk comes from not knowing what you're doing."
- Warren Buffett
(Understand the mechanism, then invest smart)
Thank you!
CTO of Starbase
Yu Yamanaka
July 18, 2017, at Yahoo! LODGE
Learn Ethereum development with the smart contract gathered $35M in 30 secs
By Yu Yamanaka
Learn Ethereum development with the smart contract gathered $35M in 30 secs
- 2,640