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
Ruby on RailsでBitcoin App開発超入門
Search
Shu Kobuchi
May 29, 2020
Programming
0
370
Ruby on RailsでBitcoin App開発超入門
Gotanda.rb#42でBitcoin×RubyのLTをさせていただきました。
https://gotanda-rb.connpass.com/event/174652/
Shu Kobuchi
May 29, 2020
Tweet
Share
More Decks by Shu Kobuchi
See All by Shu Kobuchi
生成AI入門
shukob
0
230
LangChainでWebサイトの内容取得やGitHubソースコード取得
shukob
0
450
生成AIアプリケーションにおけるRAGとデータベースの役割
shukob
0
1.2k
ビットコイン・ブロックチェーン入門
shukob
0
240
生成AI入門
shukob
2
1.1k
Mastering Bitcoin Third Editionの紹介
shukob
0
260
NFT技術概論
shukob
0
410
やさしいERC20開発
shukob
0
230
ビットコイン・ブロックチェーン入門
shukob
0
270
Other Decks in Programming
See All in Programming
CSC509 Lecture 12
javiergs
PRO
0
160
Jakarta EE meets AI
ivargrimstad
0
530
Amazon Qを使ってIaCを触ろう!
maruto
0
400
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
ヤプリ新卒SREの オンボーディング
masaki12
0
130
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
200
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Code Reviewing Like a Champion
maltzj
520
39k
The Language of Interfaces
destraynor
154
24k
GraphQLとの向き合い方2022年版
quramy
43
13k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Unsuck your backbone
ammeep
668
57k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
What's new in Ruby 2.0
geeforr
343
31k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Transcript
3VCZPO3BJMTͰ #JUDPJO"QQ։ൃೖ ݄ ۚ !(PUBOEBSC খᔹप 4IV,PCVDIJ
ࣗݾհ খᔹपɹ4IV,PCVDIJɹ!TIV@LPCTIVLPCVDIJ ·Ͱͣͬͱؔ ʙલ৬ͷ4*FSͰେࡕ͔Β౦ژసۈ େ࡚ ʙϑϨηοπ จژ۠ຊڷ w
҉߸ࢿ࢈औҾۀऀ͚ΥϨοτϕϯμʔ ۠ͪΐͬͱࡏॅɺίϩφͰϑϧϦϞʔτʹɹ 2
ίϛϡχςΟհ ຊ҉߸௨՟ϢʔβձɹIUUQTDSZQUPDVSSFODZDPOOQBTTDPN ʮϏοτίΠϯͱ͔ษڧձʯʢ݄̍ճɿฏʣ w ۚ ʙɹDMJHIUOJOH -JHIUOJOH/FUXPSL ϋϯζΦϯ ʮ҉߸௨՟ಡॻձʯʢ݄̍ճɿฏʣ
w ࣍ճௐத ΞʔΧΠϒಈըଟ͋Γ·͢ 3
ϏοτίΠϯͱ͔ ϒϩοΫνΣʔϯ ษڧͯ͠Έ͍ͨΜ͚ͩͲͶ
ϏοτίΠϯͱ͔ ϒϩοΫνΣʔϯ ษڧͯ͠Έ͍ͨΜ͚ͩͲͶ Α͘ฉ͘ηϦϑͰ͢
ϏοτίΠϯΛֶͿʹ 5FTUOFUରԠΥϨοτΛೖΕͯɺ5FTUOFUίΠϯΛૹۚͯ͠༡ΜͰΈΔ -JOVYଟগͳΓͱ৮ΕΔͳΒ #JUDPJO$PSF CJUDPJOE ΛΠϯετʔϧͯ͠ίϚϯυΛୟ͍ͯΈΔ ϓϩάϥϛϯάଟগͳΓͱͰ͖ΔͳΒ #JUDPJO$PSFͷίϚϯυΛϥοϐϯά͢ΔΞϓϦΛ։ൃ 6 .BJOOFU
5FTUOFU 3FHUFTU ελϯυΞϩϯ
#JUDPJOͱ3VCZϥΠϒϥϦͱॻ੶ #JUDPJO$PSFʢ$ ʣ IUUQTHJUIVCDPNCJUDPJOCJUDPJO CJUDPJOSCʢ3VCZϥΠϒϥϦʣ IUUQTHJUIVCDPNDIBJOUPQFCJUDPJOSC PQFOBTTFUTSCʢ3VCZϥΠϒϥϦʣ IUUQTHJUIVCDPNDIBJOUPQFPQFOBTTFUTSC ଞʹϒϩοΫνΣʔϯ3VCZϥΠϒϥϦଟ IUUQTHJUIVCDPNDIBJOUPQF
ॻ੶ʮϒϩοΫνΣʔϯɾϓϩάϥϛϯάԾ௨՟ೖʯ CJUDPJOSVCZCJUDPJOSC͕ޙܧ PQFOBTTFUTSVCZPQFOBTTFUTSC͕ޙܧ վగ༧ఆ 7
؆୯ͳγεςϜਤ CJUDPJOͷ3VCZϥΠϒϥϦʮCJUDPJOSCʯΛ༻͍ͯ#JUDPJO$PSFͱ+TPO31$ "1*Λ༻͍Δ 8 #FSLFMZ %# /P42- #JUDPJO$PSF 3VCZPO3BJMT CJUDPJOSC
ϥΠϒϥϦ DPOUSPMMFS 31$3FRVFTU +40/3FTQPOTF WJFX
CJUDPJODMJίϚϯυ IUUQTHJUIVCDPNTIVLPCSBJMTCJUDPJOSBJMTCJUDPJO ΛࢀߟʹCJUDPJOEΛΠϯετʔϧ CJUDPJODMJHFUOFXBEESFTT UCRDB[E[GSYZHVSWFEQSHE[XXGQ[YFKSB CJUDPJODMJTFOEUPBEESFTT UCRDB[E[GSYZHVSWFEQSHE[XXGQ[YFKSB GDCBFECDCCFCDBCEGFFFG DF⒎EE CJUDPJODMJHFUSBXUSBOTBDUJPO
GDCBFECDCCFCDBCEGFFFG DF⒎EE 9
CJUDPJODMJͱCJUDPJO31$ϝιουͷରԠ CJUDPJODMJHFUOFXBEESFTT UCRDB[E[GSYZHVSWFEQSHE[XXGQ[YFKSB CJUDPJODMJTFOEUPBEESFTT UCRDB[E[GSYZHVSWFEQSHE[XXGQ[YFKSB GDCBFECDCCFCDBCEGFFFG DF⒎EE CJUDPJODMJHFUSBXUSBOTBDUJPO GDCBFECDCCFCDBCEGFFFG DF⒎EE
10 bitcoinRPC('getnewaddress',[]) bitcoinRPC('sendtoaddress',[address, amount]) bitcoinRPC('getrawtransaction',[txid])
DPOUSPMMFS SBJMTOFXCJUDPJO@BQQ BQQDPOUSPMMFSTCJUDPJO@BQQ@DPOUSPMMFSSC 11 require 'bitcoin' require 'net/http' require 'json'
Bitcoin.chain_params = :regtest RPCUSER="hoge" RPCPASSWORD="hoge" HOST="localhost" PORT=18443 class BitcoinAppController < ApplicationController def index @blockchaininfo = bitcoinRPC('getblockchaininfo',[]) render template: ‘bitcoin_app/index' end private def bitcoinRPC(method,param) http = Net::HTTP.new(HOST, PORT) request = Net::HTTP::Post.new('/') request.basic_auth(RPCUSER,RPCPASSWORD) request.content_type = 'application/json' request.body = {method: method, params: param, id: 'jsonrpc'}.to_json JSON.parse(http.request(request).body)["result"] end end end bitcoinRPC('getblockchaininfo',[])
WJFXͱSPVUFT BQQWJFXTCJUDPJO@BQQJOEFYIUNMFSC 12 DPOpHSPVUFTSC <td><%= @blockchaininfo %></td> Rails.application.routes.draw do get
'/', to: 'bitcoin_app#index' get '/index', to: 'bitcoin_app#index' end SBJMTT
։ൃྫ ϒϩοΫϋογϡɺϒϩοΫߴɺτϥϯβΫγϣϯ*%ɺΞυϨεͱ͍͏छྨ Λݕࡧ૭ͭͰ͍͍ͯ͞Δ ܧଓ։ൃதɿIUUQTHJUIVCDPNTIVLPCSBJMTCJUDPJO 13
ࢀߟࢿྉ
ϒϩοΫνΣʔϯΤΫεϓϩʔϥ ༷ʑͳ։ൃݩ͔ΒϒϩοΫνΣʔϯΤΫεϓϩʔϥ͕ఏڙ͞Ε͍ͯΔ IUUQTCMPDLTUSFBNJOGP IUUQTHJUIVCDPNCMPDLTUSFBNFTQMPSB w #MPDLTUSFBNFTQMPSB044ʢ3VCZͰͳ͍ʣ 15
ϒϩοΫҰཡ ϒϩοΫνΣʔϯΤΫεϓϩʔϥͷτοϓϒϩοΫҰཡͰ͋Δ͜ͱ͕ଟ͍ τοϓͷϒϩοΫҰཡ͕JOEFYʹ͢Δ ϧʔςΟϯάઃఆ CJUDPJODMJHFUCMPDLDIBJOJOGPͰ࠷৽ϒϩοΫߴΛऔಘ ࠷৽ϒϩοΫߴ͔Β߱ॱʹ CJUDPJODMJHFUCMPDLIBTICMPDLIFJHIUͰϒϩοΫϋογϡΛಘͯɺ CJUDPJODMJHFUCMPDLCMPDLIBTIͰϒϩοΫͷதΛಘΔ ϒϩοΫͷ͕ଟ͘ͳͬͨΒɺϖʔδωʔγϣϯΛೖΕΔ 16
ϒϩοΫͷใ ؆୯ HFUCMPDLCMPDLIBTIͷΑ͏ͳײ͡ͰΫΤϦʹϒϩοΫϋογϡ CJUDPJODMJHFUCMPDLCMPDLIBTI Ϩεϙϯεͷ+TPOΛ7JFXʹૹΓ͜ΜͰඞཁͳσʔλΛදࣔ HFUCMPDLͷ͍͍ͱ͜Ζঝೝ࣍ͷϒϩοΫϋογϡؚΊͯڭ͑ͯ͘ΕΔ ͪΖΜલͷϒϩοΫϋογϡ 17
ΞϦε͕Ϙϒʹ#5$ΛૹΔ Ҏલड͚औֹ͍ͬͯͨΛ߹ࢉͯ͠ɺ૬खʹૹΓɺ͓Γࣗ 59தʹهࡌͷͳֹ͍ ͜͜Ͱ#5$ ޙʹϚΠφʔ τϥϯβΫγϣϯ5SBOTBDUJPO59 18 ΞϦε Ϙϒ 5SBOTBDUJPO
59 */165 065165 ΞϦε Ωϟϩϧ ΞϦεˠϘϒ #5$ ΩϟϩϧˠΞϦε #5$ ΞϦεˠΞϦε ͓Γ #5$ #5$ σϏοτˠΞϦε #5$ #5$ σϏοτ ܭ#5$ ܭ#5$ ϚΠφʔ ωοτϫʔΫखྉ #5$ ˞59ʹهࡌͳ͍ ൿີ伴Λࠩ͠ࠐΜͰ ϩοΫղআɿిࢠॺ໊ ΞϦεͷ ൿີ伴 ΞϦεͷ ൿີ伴 ΞϦεͷ ެ։伴 Ϙϒͷ ެ։伴 ΞϦεͷ ެ։伴 ΞϦεͷ ެ։伴
τϥϯβΫγϣϯใ ໘ HFUUYUYJEͷΑ͏ͳײ͡ͰUYJEΛΫΤϦʹ CJUDPJODMJHFUSBXUSBOTBDUJPOUYJE SFTQPOTFSBXUSBOTBDUJPO CJUDPJODMJEFDPEFSBXUSBOTBDUJPOSBXUSBOTBDUJPO SFTQPOTFͷதʹPVUQVUͷΞυϨεɾૹֹؚۚ·ΕΔ͕ɺJOQVUͷΞυ Ϩεɾֹखྉؚ·Εͳ͍ w CJUDPJODMJHFUUSBOTBDUJPOUYJEͩͱڭ͑ͯ͘ΕΔ͕ɺ#JUDPJO$PSF
ࣗͷXBMMFUͷUYͷΈ JOQVU෦ WJO ͷUYJE WPVU͔ΒHFUSBXUSBOTBDUJPO EFDPEFSBXUSBOTBDUJPOͰJOQVUͷΞυϨεͱֹΛٻΊΔ खྉʹJOQVU෦ͷ߹ܭֹʔPVUQVU෦ͷ߹ܭֹ 19
τϥϯβΫγϣϯͷঝೝɺ༻ࡁ EFDPEFSBXUSBOTBDUJPOSBXUSBOTBDUJPOͷ3FTQPODFʹϒϩοΫঝೝ ؚ·Ε͍ͯͳ͍ CJUDPJODMJHFUCMPDLDIBJOJOGPͰ࠷৽ͷϒϩοΫߴΛऔಘ ࠷৽ͷϒϩοΫߴ͔Β߱ॱʹHFUCMPDLIBTI HFUCMPDLͰϒϩοΫͷUYJEΛ ݟ͍͖ͯɺରͷUYΛؚΉϒϩοΫ͔ΒঝೝΛಘΔ CJUDPJODMJHFUUYPVUUYJEWPVU͕ଘࡏ͢Εະ༻ɺͳ͚Ε༻ࡁ 20
औΓѻ͍ҙͷ59 $PJOCBTF59ͷ*OQVU WJOʹUYJE͕ͳ͍ͳͲͯ͠ผ (FOFTJT#MPDLͷ59 CJUDPJODMJHFUSBXUSBOTBDUJPOUYJEͰऔಘͰ͖ͳ͍ ϋʔυίʔσΟϯά͞Εͨ59 59*% BFFCBBCGBBDCDGGFDDBCCBGE
FEBC ͜ͷ59*%.BJOOFU 5FTUOFU 3FHUFTU 4JHOFUڞ௨ 21
ΞυϨεใ HFUBEESFTTBEESFTTͷΑ͏ͳײ͡ͰBEESFTTΛΫΤϦʹ ͓ΈͰCJUDPJODMJWBMJEBUFBEESFTTBEESFTTͰ༗ޮͳΞυϨε͔Ͳ͏͔ CJUDPJODMJHFUSBXNFNQPPMͰNFNQPPMͷUYJEΛऔಘ CJUDPJODMJHFUCMPDLDIBJOJOGPͰ࠷৽ͷϒϩοΫߴΛऔಘ ࠷৽ͷϒϩοΫߴ͔Β߱ॱʹHFUCMPDLIBTI HFUCMPDLͰϒϩοΫͷUYJEΛ औಘ HFUSBXUSBOTBDUJPOUYJE EFDPEFSBXUSBOTBDUJPOSBXUSBOTBDUJPOͰ
WPVUʹΞυϨε͕͋Δ͔ΛݟΔ WJOͷUYJEHFUSBXUSBOTBDUJPOUYJE EFDPEFSBXUSBOTBDUJPO SBXUSBOTBDUJPOͰWPVUʹΞυϨε͕͋Δ͔ΛݟΔ ΞυϨεʹؔ͋Δ59ͷใΛ࣌ܥྻͷ߱ॱʹฒΔ NFNQPPMͷ59͕Ұ൪্ ঝೝͳͲτϥϯβΫγϣϯҰཡΛࢀߟʹ 22
ΞυϨεใ CJUDPJODMJHFUUYPVUUYJEWPVU͕ଘࡏ͢Εະ༻ɺͳ͚Ε༻ࡁ ະ༻ͷ6590Λ͔͖ूΊͯߴܭࢉ͕Մೳ $PJOCBTF59ঝೝ͠ͳ͍ͱ͑ͳ͍ ΞυϨεҰཡը໘ͰΞυϨεʹؔ͢Δશ59ͷঝೝ·ͰٻΊ͍ͯͨΒॲཧ ͕ऴΘΒͳ͍ʢۤসʣ3FHUFTUͰ ͦΖͦΖ%#ͷग़൪ 23
ݕࡧ ϒϩοΫϋογϡɺϒϩοΫߴɺ59*%ɺΞυϨεͰͷݕࡧϑΟʔϧυ QPTU ύϥϝʔλͷαΠζ͕ͷ߹ ϒϩοΫϋογϡ͔59*% BFFCBBCGBBDCDGGFDDBCC BGEFEBCͷ߹ɺ(FOFTJTϒϩοΫͷ59*% HFUSBXUSBOTBDUJPOUYJEͰϨεϙϯε͕͋Ε59 HFUCMPDLIBTICMPDLIBTIͰϨεϙϯε͕͋ΕϒϩοΫ
ύϥϝʔλͷαΠζ͕ɺ .BJOOFUɾ4JHOFUCFDI ɾ 5FTUOFUɾ 3FHUFTU CFDI ͷ͍ͣΕ͔ͷ߹ΞυϨε ύϥϝʔλ͕ͷ߹ɺϒϩοΫߴ HFUCMPDLIBTIQBSBNTͰϨεϙϯε͕͋ΕɺϒϩοΫ ͦΕͧΕɺϒϩοΫใɺτϥϯβΫγϣϯใɺΞυϨεใͷؔʹ SFEJSFDU ͍ͣΕͰͳ͍߹OPUGPVOEը໘ 24