Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
gethoハッカソン -ハンズオン-
Search
daisuke sato
December 01, 2018
Technology
1
1k
gethoハッカソン -ハンズオン-
gethoハッカソンの時のハンズオンの内容です。
daisuke sato
December 01, 2018
Tweet
Share
More Decks by daisuke sato
See All by daisuke sato
BlockchainHackathon2019 ワークショップ ~ Twitterとブロックチェーンを使ったアイデンティフィケーションの実現~
daisuke310vvv
0
210
gethoとTruffleを使った DApps開発ワークショップ
daisuke310vvv
0
140
Hi-Con2018 より良いDApp開発をするための話と gethoについて
daisuke310vvv
1
360
getho ~ Ethereum private nodes, tailored for you. ~
daisuke310vvv
0
740
社内仮想通貨をモバイルDappとしてつくってみた
daisuke310vvv
1
3k
Other Decks in Technology
See All in Technology
カメラを用いた店内計測におけるオプトインの仕組みの実現 / ai-optin-camera
cyberagentdevelopers
PRO
1
120
AIを駆使したゲーム開発戦略: 新設AI組織の取り組み / sge-ai-strategy
cyberagentdevelopers
PRO
1
130
バクラクにおける可観測性向上の取り組み
yuu26
3
400
コンテンツを支える 若手ゲームクリエイターの アートディレクションの事例紹介 / cagamefi-game
cyberagentdevelopers
PRO
1
120
アジャイルと契約 エッセンシャル版 / Agile Contracts Essential Edition
fkino
0
110
端末が簡単にリモートから操作されるデモを通じて ソフトウェアサプライチェーン攻撃対策の重要性を理解しよう
kitaji0306
0
170
グローバル展開を見据えたサービスにおける機械翻訳プラクティス / dp-ai-translating
cyberagentdevelopers
PRO
1
150
[JAWS-UG金沢支部×コンテナ支部合同企画]コンテナとは何か
furuton
3
230
マネジメント視点でのre:Invent参加 ~もしCEOがre:Inventに行ったら~
kojiasai
0
440
オーティファイ会社紹介資料 / Autify Company Deck
autifyhq
9
120k
Amazon_CloudWatch_ログ異常検出_導入ガイド
tsujiba
4
1.5k
ガチ勢によるPipeCD運用大全〜滑らかなCI/CDを添えて〜 / ai-pipecd-encyclopedia
cyberagentdevelopers
PRO
3
200
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
290
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Being A Developer After 40
akosma
86
590k
A Philosophy of Restraint
colly
203
16k
Why You Should Never Use an ORM
jnunemaker
PRO
53
9k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
3
370
Making Projects Easy
brettharned
115
5.9k
Statistics for Hackers
jakevdp
796
220k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
How GitHub (no longer) Works
holman
311
140k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Transcript
getho Hackathon ϋϯζΦϯ
ࣗݾհ ໊લ: ࠤ౻ େี(@st_dsk) ձࣾ: Popshoot, Inc ݴޠ: Golang, Swift,
ຊޠ, ӳޠ ࣄ: Server/Infra ΤϯδχΞ, iOS
ࠓ͢͜ͱ 1. ΠʔαϦΞϜʹ͍ͭͯ 2. εϚʔτίϯτϥΫτʹ͍ͭͯ 3. DApp։ൃπʔϧʹ͍ͭͯ 4. gethoʹ͍ͭͯ 5.
؆୯ͳτʔΫϯͷ࡞ͱσϓϩΠ 6. ToDoΞϓϦͷհ
ࠓ͢͜ͱ 1. ΠʔαϦΞϜʹ͍ͭͯ 2. εϚʔτίϯτϥΫτʹ͍ͭͯ 3. DApp։ൃπʔϧʹ͍ͭͯ 4. gethoʹ͍ͭͯ 5.
؆୯ͳτʔΫϯͷ࡞ͱσϓϩΠ 6. ToDoΞϓϦͷհ
ΠʔαϦΞϜʹ͍ͭͯ • Ծ௨՟ͷҰछ(ETH) • ΞϓϦέʔγϣϯϓϥοτϑΥʔϜ • BTCͱETHͷҧ͍? • BTC௨՟ͱͯ͠ͷׂ͕ϝΠϯ •
ETHΞϓϦέʔγϣϯΛಈ͔͢ ͨΊͷͷ೩ྉ(Ψε)
ࠓ͢͜ͱ 1. ΠʔαϦΞϜʹ͍ͭͯ 2. εϚʔτίϯτϥΫτʹ͍ͭͯ 3. DApp։ൃπʔϧʹ͍ͭͯ 4. gethoʹ͍ͭͯ 5.
؆୯ͳτʔΫϯͷ࡞ͱσϓϩΠ 6. ToDoΞϓϦͷհ
εϚʔτίϯτϥΫτʹ͍ͭͯ • εϚʔτίϯτϥΫτ • ΠʔαϦΞϜͰಈ͘ΞϓϦέʔγϣϯ • ϊʔυʹঢ়ଶΛ࣋ͭ • ίϯτϥΫτΞυϨε •
։ൃݴޠ • Solidity, Vyper ͳͲ
Solidity • Solidity • εϚʔτίϯτϥΫτΛ࣮͢ΔͨΊͷݴޠ • EVMίʔυʹίϯύΠϧ͞ΕΔ • JavascriptϥΠΫ
Solidity pragma solidity ^0.4.24; contract SimpleStore { uint value; function
set(uint _value) public { value = _value; } function get() public constant returns (uint) { return value; } }
Solidityݴޠ༷ boolean • true or false uint v = 123
!true // => false v == 123 // => true v != 123 // => false v == 123 && true // => true v == 123 || false // => true
Solidityݴޠ༷ intergers • (u)int • (u)int8 ~ (u)int256 • int/uint(u)int256ͷΤΠϦΞε
uint x = 3 x = x + 5 // => 8 x = x * 5 // => 40 x = x / 5 // => 8 x = x % 5 // => 3
Solidityݴޠ༷ address • 20byteͷ(ΠʔαϦΞϜΞυϨε) • address or address payable(>=0.5.0) address
payable x = address(0x123); address myAddress = address(this); if (x.balance < 10 && myAddress.balance >= 10) x.transfer(10);
Solidityݴޠ༷ array uint[2] fixedArr; fixedArr[0] = 10; // [10, 0]
arr.length; // 2 string[] arr; arr.push("apple"); // [apple] arr.push("banana"); // [apple,banana]
Solidityݴޠ༷ struct struct Person { address addr; string name; uint8
age; } Person memory p = Person(address(0xabc...), "Vitalik", 24); p.age // => 24
Solidityݴޠ༷ mapping mapping(address => uint) public balances; balances[msg.sender] = 100;
balances[msg.sender] // => 100;
Solidityݴޠ༷ forจ for(int i = 0; i < 20; i++)
{ // do something }
Solidityݴޠ༷ ifจ uint a = 1; uint b = 2;
if (a == b) { // do something } else if (a != b) { // do something } else { // do something }
Solidityݴޠ༷ Time 1 == 1 seconds 1 minutes == 60
seconds 1 hours == 60 minutes 1 days == 24 hours 1 weeks == 7 days
Solidityݴޠ༷ Block, Transaction Properties • blockhash(uint blockNumber) returns (bytes32) •
block.gaslimit: uint • block.number: uint • block.timestamp: uint • tx.gasprice: uint
Solidityݴޠ༷ ͦͷଞ • msg.sender: address payable • msg.value: uint •
now: uint
Solidityݴޠ༷ storageͱmemory • storage • ϒϩοΫνΣʔϯ্ʹΔ • gas͕͔͔Δ • memory
• ϒϩοΫνΣʔϯ্ʹΒͳ͍ • gas͕͔͔Βͳ͍
Solidityݴޠ༷ Function function (<parameter types>) {internal|external} [pure|view|payable] [returns (<return types>)]
• pure, view, payable • pure: storageͷΞΫηεෆՄ • view: storageͷࢀরͷΈՄ • payable: ETHͷૹ͖ۚ
Solidityݴޠ༷ Modifier • ࣮ؔߦ࣌ʹҙͷॲཧΛ࣮ߦ͢Δ contract A { address owner; modifier
onlyOwner { require(msg.sender == owner); _; } function doSomething() public onlyOwner { // do something if owner } }
ࠓ͢͜ͱ 1. ΠʔαϦΞϜʹ͍ͭͯ 2. εϚʔτίϯτϥΫτʹ͍ͭͯ 3. DApp։ൃπʔϧʹ͍ͭͯ 4. gethoʹ͍ͭͯ 5.
؆୯ͳτʔΫϯͷ࡞ͱσϓϩΠ 6. ToDoΞϓϦͷհ
DApp։ൃ4େπʔϧ • ݴޠ(solidity, vyper) • ϑϨʔϜϫʔΫ(truffle, emberk) • IDE(Remix, EthFiddle)
• ςετ༻ϒϩοΫνΣʔϯωοτϫʔΫ(ganache, getho)
DApp։ൃπʔϧ • web3.js • Truffle • OpenZeppelin • MetaMask
DApp։ൃπʔϧ web3.js • ϊʔυʹΞΫηε͢ΔͨΊͷϥΠϒϥϦ var Web3 = require('web3'); var web3
= new Web3(); web3.setProvider(new web3.providers.HttpProvider('http://127.0.0.1:8545')); (web3.eth.getBalance("0x...");
DApp։ൃπʔϧ Truffle • εϚʔτίϯτϥΫτΛ։ൃ͢ΔͨΊͷϑϨʔϜϫʔΫ $ truffle init $ truffle compile
$ truffle migrate
DApp։ൃπʔϧ OpenZeppelin • εϚʔτίϯτϥΫτͷςϯϓϨʔτɺϥΠϒϥϦ • ERC20, ERC721, SafeMathͳͲ
DApp։ൃπʔϧ MetaMask • ϒϥβΥϨοτ • ETHτʔΫϯͷߴࢀরɺૹۚ • web3ͱ࿈ܞՄೳ
ࠓ͢͜ͱ 1. ΠʔαϦΞϜʹ͍ͭͯ 2. εϚʔτίϯτϥΫτʹ͍ͭͯ 3. DApp։ൃπʔϧʹ͍ͭͯ 4. gethoʹ͍ͭͯ 5.
؆୯ͳτʔΫϯͷ࡞ͱσϓϩΠ 6. ToDoΞϓϦͷհ
getho DApp։ൃͷͨΊͷ։ൃϓϥοτϑΥʔϜ ಛ - ςετ༻ϒϩοΫνΣʔϯωοτϫʔΫ - εϚʔτίϯτϥΫτͷ࣮ߦڥ
getho Dashboard • ؆୯ʹىಈ • τϥϯβΫγϣϯཤྺ • σϑΝϧτΞΧϯτ
None
getho ίϯτϥΫτ࣮ߦ • GUI্Ͱ࣮ߦ • ࣮ߦ݁Ռ
None
ࠓ͢͜ͱ 1. ΠʔαϦΞϜʹ͍ͭͯ 2. εϚʔτίϯτϥΫτʹ͍ͭͯ 3. DApp։ൃπʔϧʹ͍ͭͯ 4. gethoʹ͍ͭͯ 5.
؆୯ͳτʔΫϯͷ࡞ͱσϓϩΠ 6. ToDoΞϓϦͷհ
؆୯ͳτʔΫϯͷ࡞ͱσϓϩΠ • ࡞Δͷ • ERC20τʔΫϯ • ։ൃڥ • Node •
Truffle • OpenZeppelin • getho
લ४උᶃ • gethoΞΧϯτੜ • ͪ͜Β͔Β => https://getho.io
લ४උᶄ • Πϯετʔϧ $ brew install node // Windows or
Linuxͷ߹దٓ $ npm install -g truffle $ npm install -g openzeppelin-solidity
લ४උᶅ • σΟϨΫτϦੜ $ mkdir ~/HackathonToken $ cd ~/HackathonToken •
truffleͷॳظԽ $ truffle init
contractsʹϑΝΠϧΛՃ $ touch ./contracts/HackathonToken.sol $ vim ./contracts/HackathonToken.sol // ΤσΟλΛ։͘
HackathonTokenͷ࣮ pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol"; contract HackathonToken
is ERC20, ERC20Detailed { constructor( string name, string symbol, uint8 decimals, uint256 initialSupply ) ERC20Detailed(name, symbol, decimals) ERC20() public {} }
migrationsʹϑΝΠϧΛՃ $ touch ./migrations/2_deploy_hackathon.js $ vim ./migrations/2_deploy_hackathon.js // ΤσΟλΛ։͘
σϓϩΠ༻ͷmigrationίʔυΛ࣮ var hackathon = artifacts.require("./HackathonToken.sol"); module.exports = function(deployer){ var name
= "Hackathon Token"; var symbol = "HKT"; var decimals = 18; var initialSupply = 1000000e18 deployer.deploy(hackathon, name, symbol, decimals, initialSupply, { }) }
truffle.jsʹωοτϫʔΫͷՃ $ vim ./truffle.js // ΤσΟλΛ։͘ module.exports = { networks:
{ getho: { host: "<YOUR SUBDOMAIN>.getho.io/jsonrpc", port: 80, gas: 4712388, network_id: 1010 } } };
gethoʹσϓϩΠ $ truffle migrate --network getho // => gethoͰτϥϯβΫγϣϯ֬ೝ
ίϯτϥΫτΛgethoʹొ $ brew tap popshootjapan/homebrew-getho $ brew install getho //
or go get github.com/popshootjapan/getho $ getho login $ getho upload ./build/contracts/HackathonToken.json \ -s <YOUR SUBDOMAIN> // => gethoͰίϯτϥΫτ࣮ߦ ※ gethoཧը໘্͔ΒొͰ͖·͢
ࠓ͢͜ͱ 1. ΠʔαϦΞϜʹ͍ͭͯ 2. εϚʔτίϯτϥΫτʹ͍ͭͯ 3. DApp։ൃπʔϧʹ͍ͭͯ 4. gethoʹ͍ͭͯ 5.
؆୯ͳτʔΫϯͷ࡞ͱσϓϩΠ 6. ToDoΞϓϦͷհ
ToDoΞϓϦͷհ • WebΞϓϦέʔγϣϯ http://<ip>:3000/ • ιʔείʔυ https://github.com/daisuke310vvv/web3todo
ϋοΧιϯΛ ָ͠Έ·͠ΐ͏ʂʂ