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
2018 - How the Rubyist use Blockchain
Search
蒼時弦や
May 07, 2018
Technology
0
120
2018 - How the Rubyist use Blockchain
The talks about ruby and blockchain in rubyelixirconftw.
蒼時弦や
May 07, 2018
Tweet
Share
More Decks by 蒼時弦や
See All by 蒼時弦や
2024 - COSCUP - Clean Architecture in Rails
elct9620
2
140
2023 - RubyConfTW - Rethink Rails Architecture
elct9620
0
110
20230916 - DDDTW - 導入 Domain-Driven Design 的最佳時機
elct9620
0
380
2023 - WebConf - 選擇適合你的技能組合
elct9620
0
600
20230322 - Generative AI 小聚 ft. Happy Designer
elct9620
0
320
2022 - 默默會 - 重新學習 MVC 的 Model
elct9620
1
420
MOPCON 2022 - 從 Domain-Driven Design 看網站開發框架隱藏
elct9620
1
440
2022 - COSCUP - 我想慢慢寫程式該怎麼辦?
elct9620
0
220
2022 - COSCUP - 打造高速 Ruby 專案開發流程
elct9620
0
250
Other Decks in Technology
See All in Technology
地方拠点で エンジニアリングマネージャーってできるの? 〜地方という制約を楽しむオーナーシップとコミュニティ作り〜
1coin
1
230
運用しているアプリケーションのDBのリプレイスをやってみた
miura55
1
720
Oracle Cloud Infrastructure:2025年2月度サービス・アップデート
oracle4engineer
PRO
1
210
君も受託系GISエンジニアにならないか
sudataka
2
430
「海外登壇」という 選択肢を与えるために 〜Gophers EX
logica0419
0
700
開発スピードは上がっている…品質はどうする? スピードと品質を両立させるためのプロダクト開発の進め方とは #DevSumi #DevSumiB / Agile And Quality
nihonbuson
2
2.9k
現場で役立つAPIデザイン
nagix
33
12k
滅・サービスクラス🔥 / Destruction Service Class
sinsoku
6
1.6k
開発組織のための セキュアコーディング研修の始め方
flatt_security
3
2.4k
プロダクトエンジニア構想を立ち上げ、プロダクト志向な組織への成長を続けている話 / grow into a product-oriented organization
hiro_torii
1
190
リアルタイム分析データベースで実現する SQLベースのオブザーバビリティ
mikimatsumoto
0
1.4k
次世代KYC活動報告 / 20250219-BizDay17-KYC-nextgen
oidfj
0
250
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
630
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.5k
Testing 201, or: Great Expectations
jmmastey
42
7.2k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
27
1.9k
Writing Fast Ruby
sferik
628
61k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
Fontdeck: Realign not Redesign
paulrobertlloyd
83
5.4k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
Transcript
How the Rubyist use Blockchain
WEB DEVELOPER GAME DEVELOPER 襟 儘 䓛⛳ @elct9620
None
I will talk about What is the Blockchain The examples
use Ruby and Ethereum
What is the Blockchain
Linked List Cryptography Key-Value Data Store Distributed System
There is nothing new for us
None
Cryptocurrency
None
So, how the Blockchain works?
Chain =~ Linked List
The Chain Block #1 Block #2 Block #3 Pointer Pointer
Ok, I think you already learned it!
But, we have to limit anyone to write it!!!
1. Proof of Work
1. Prevent mass request from somebody 2. Other people can
verify in short time Cryptography
Use cryptography to resolve question!
Cryptography Network Hash start with “000” Workers Define a Question
Broadcast
Cryptography Workers 000abcdefaaabc… Network Try hash block Submit
Cryptography Network 000abcdefaaabc Block Created Verify result Accept
Wait! The same content will get the same hash result!
None
We add a random “Proof” string with block data
So, the worker should spend the time
And others can check it in short time
If we receive many correct answers…
Which one should accept?
2. Byzantine Generals Problem
Distributed 1. Longest is right 2. 51% node think it
is right
But, we didn’t discuss the algorithm in this talk
And last
How the Blockchain save data?
Merkle Tree
None
Very useful to update and verify data
But read will spend more time
Should I use pure ruby gem to operate blockchain?
It is hard to implement the same API in pure
Ruby
Use the existed API to operate Blockchain.
But, you can implement blockchain in Ruby
Example Ethereum’s IPC Use Ruby to operate Ethereum
IPC =~ UnixSocket
None
How to get IPC and comminuted with it?
IPC 1. Ethereum Wallet 2. brew install geth 3. Compile
from source code
“geth —light —testnet”
But I suggest using Ethereum Wallet
Because you can find IPC file very easy
But how to use UnixSocket to operate Ethereum?
JSON-RPC 2.0
None
None
And it always ends with a linefeed (\n)
None
None
Now, we can interact with Ethereum in Ruby
But the result has many hash value
What are the meaning and real data?
Ethereum Data 1. Call another API to get transaction value
2. Read from “data” depend on ABI
If we just want to know transaction value
It always contains in API response
So, we talk about smart contract event
None
But we got the data in hex
None
It always returns the 32byte hex string for us
So, we need ABI to help us know the data
type
None
Demo - Subscribe event and get data
Now, we know what can we do on the Ethereum
And last, is there has any useful resource?
Ruby Reference 1. digest-sha3 2. rlp 3. ruby-ethereum 4. Naivechain.rb
Conclusion
Build a blockchain in Ruby can help us learn it
And didn’t try to write a client in pure ruby
THANKS