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
130
2023 - RubyConfTW - Rethink Rails Architecture
elct9620
0
100
20230916 - DDDTW - 導入 Domain-Driven Design 的最佳時機
elct9620
0
370
2023 - WebConf - 選擇適合你的技能組合
elct9620
0
580
20230322 - Generative AI 小聚 ft. Happy Designer
elct9620
0
310
2022 - 默默會 - 重新學習 MVC 的 Model
elct9620
1
410
MOPCON 2022 - 從 Domain-Driven Design 看網站開發框架隱藏
elct9620
1
430
2022 - COSCUP - 我想慢慢寫程式該怎麼辦?
elct9620
0
220
2022 - COSCUP - 打造高速 Ruby 專案開發流程
elct9620
0
240
Other Decks in Technology
See All in Technology
怖くない!ゼロから始めるPHPソースコードコンパイル入門
colopl
0
190
GitHub Copilot のテクニック集/GitHub Copilot Techniques
rayuron
41
18k
最近のSfM手法まとめ - COLMAP / GLOMAPを中心に -
kwchrk
8
1.5k
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
28
24k
pg_bigmをRustで実装する(第50回PostgreSQLアンカンファレンス@オンライン 発表資料)
shinyakato_
0
120
組織に自動テストを書く文化を根付かせる戦略(2024冬版) / Building Automated Test Culture 2024 Winter Edition
twada
PRO
21
6.1k
メンタル面でもつよつよエンジニアになる/登壇資料(井田 献一朗)
hacobu
0
150
いまからでも遅くないコンテナ座学
nomu
0
160
[JAWS-UG新潟#20] re:Invent2024 -CloudOperationsアップデートについて-
shintaro_fukatsu
0
130
OCI技術資料 : ファイル・ストレージ 概要
ocise
3
11k
レンジャーシステムズ | 会社紹介(採用ピッチ)
rssytems
0
330
なぜCodeceptJSを選んだか
goataka
0
190
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
Embracing the Ebb and Flow
colly
84
4.5k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
18
2.3k
GraphQLとの向き合い方2022年版
quramy
44
13k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
230
52k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Designing for Performance
lara
604
68k
Six Lessons from altMBA
skipperchong
27
3.5k
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