Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby on RailsでBitcoin App開発超入門

Ruby on RailsでBitcoin App開発超入門

Gotanda.rb#42でBitcoin×RubyのLTをさせていただきました。
https://gotanda-rb.connpass.com/event/174652/

Shu Kobuchi

May 29, 2020
Tweet

More Decks by Shu Kobuchi

Other Decks in Programming

Transcript

  1. 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',[])
  2. ΞϦε͕Ϙϒʹ#5$ΛૹΔ Ҏલड͚औֹ͍ͬͯͨΛ߹ࢉͯ͠ɺ૬खʹૹΓɺ͓௼Γ͸ࣗ෼΁ 59தʹهࡌͷͳֹ͍ ͜͜Ͱ͸#5$ ͸ޙʹϚΠφʔ΁ τϥϯβΫγϣϯ5SBOTBDUJPO59 18 ΞϦε Ϙϒ 5SBOTBDUJPO

    59 */165 065165 ΞϦε Ωϟϩϧ ΞϦεˠϘϒ #5$ ΩϟϩϧˠΞϦε #5$ ΞϦεˠΞϦε ͓௼Γ  #5$ #5$ σϏοτˠΞϦε #5$ #5$ σϏοτ ܭ#5$ ܭ#5$ ϚΠφʔ ωοτϫʔΫख਺ྉ #5$ ˞59ʹهࡌ͸ͳ͍ ൿີ伴Λࠩ͠ࠐΜͰ ϩοΫղআɿిࢠॺ໊ ΞϦεͷ ൿີ伴 ΞϦεͷ ൿີ伴 ΞϦεͷ ެ։伴 Ϙϒͷ ެ։伴 ΞϦεͷ ެ։伴 ΞϦεͷ ެ։伴
  3. ݕࡧ ϒϩοΫϋογϡɺϒϩοΫߴɺ59*%ɺΞυϨεͰͷݕࡧϑΟʔϧυ QPTU  ύϥϝʔλͷαΠζ͕ͷ৔߹ ϒϩοΫϋογϡ͔59*% BFFCBBCGBBDCDGGFDDBCC BGEFEBCͷ৔߹͸ɺ(FOFTJTϒϩοΫͷ59*% HFUSBXUSBOTBDUJPOUYJEͰϨεϙϯε͕͋Ε͹59 HFUCMPDLIBTICMPDLIBTIͰϨεϙϯε͕͋Ε͹ϒϩοΫ

    ύϥϝʔλͷαΠζ͕ɺ .BJOOFUɾ4JHOFUCFDI ɾ 5FTUOFUɾ 3FHUFTU CFDI ͷ͍ͣΕ͔ͷ৔߹͸ΞυϨε ύϥϝʔλ͕਺஋ͷ৔߹ɺϒϩοΫߴ HFUCMPDLIBTIQBSBNTͰϨεϙϯε͕͋Ε͹ɺϒϩοΫ ͦΕͧΕɺϒϩοΫ৘ใɺτϥϯβΫγϣϯ৘ใɺΞυϨε৘ใͷؔ਺ʹ SFEJSFDU ͍ͣΕͰ΋ͳ͍৔߹OPUGPVOEը໘ 24