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
370
getho ~ Ethereum private nodes, tailored for you. ~
daisuke310vvv
0
750
社内仮想通貨をモバイルDappとしてつくってみた
daisuke310vvv
1
3k
Other Decks in Technology
See All in Technology
re:Invent 2024 Innovation Talks(NET201)で語られた大切なこと
shotashiratori
0
310
alecthomas/kong はいいぞ / kamakura.go#7
fujiwara3
1
300
How to be an AWS Community Builder | 君もAWS Community Builderになろう!〜2024 冬 CB募集直前対策編?!〜
coosuke
PRO
2
2.8k
フロントエンド設計にモブ設計を導入してみた / 20241212_cloudsign_TechFrontMeetup
bengo4com
0
1.9k
OpenAIの蒸留機能(Model Distillation)を使用して運用中のLLMのコストを削減する取り組み
pharma_x_tech
4
560
NW-JAWS #14 re:Invent 2024(予選落ち含)で 発表された推しアップデートについて
nagisa53
0
260
Amazon Kendra GenAI Index 登場でどう変わる? 評価から学ぶ最適なRAG構成
naoki_0531
0
110
20241214_WACATE2024冬_テスト設計技法をチョット俯瞰してみよう
kzsuzuki
3
450
小学3年生夏休みの自由研究「夏休みに Copilot で遊んでみた」
taichinakamura
0
150
Opcodeを読んでいたら何故かphp-srcを読んでいた話
murashotaro
0
230
Qiita埋め込み用スライド
naoki_0531
0
4.8k
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
Featured
See All Featured
BBQ
matthewcrist
85
9.4k
YesSQL, Process and Tooling at Scale
rocio
169
14k
GraphQLとの向き合い方2022年版
quramy
44
13k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Optimising Largest Contentful Paint
csswizardry
33
3k
A Tale of Four Properties
chriscoyier
157
23k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
A designer walks into a library…
pauljervisheath
204
24k
How STYLIGHT went responsive
nonsquared
95
5.2k
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
ϋοΧιϯΛ ָ͠Έ·͠ΐ͏ʂʂ