Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
2018 - How the Rubyist use Blockchain
蒼時弦や
May 07, 2018
Technology
0
72
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 蒼時弦や
2022 - 默默會 - 重新學習 MVC 的 Model
elct9620
1
250
MOPCON 2022 - 從 Domain-Driven Design 看網站開發框架隱藏
elct9620
0
280
2022 - COSCUP - 我想慢慢寫程式該怎麼辦?
elct9620
0
130
2022 - COSCUP - 打造高速 Ruby 專案開發流程
elct9620
0
150
2021 - RubyKaigi - It is time to build your mruby VM on the microcontroller?
elct9620
0
54
2021 - TGDF - Unlight 從 TCP 到 WebSocket 的 HTML5 之路
elct9620
0
120
2020 - MOPCON - 拿到錘子的我想在為控制器上實作 Ruby VM
elct9620
0
66
2020 - COSCUP - 你這段 Ruby Code 超速摟,已經沒有人看得懂了!
elct9620
0
77
2019 - PVE 社群 - Rails 串接 Proxmox VE API 自動化教學用虛擬機分配
elct9620
1
540
Other Decks in Technology
See All in Technology
Multi-Cloud Gatewayでデータを統治せよ!/ Data Federation with MCG
tutsunom
1
300
初めてのデータ移行プロジェクトから得た学び
tjmtmmnk
0
360
ユーザーテストガイドライン VERSION 2.0
kouzoukaikaku
0
1.4k
Exploring MapStore Release 2022.02: improved 3DTiles support and more
simboss
PRO
0
380
02_プロトタイピングの進め方
kouzoukaikaku
0
550
20230123_FinJAWS
takuyay0ne
0
120
AWS re:Invent 2022で発表された新機能を試してみた ~Cloud OperationとSecurity~ / New Cloud Operation and Security Features Announced at AWS reInvent 2022
yuj1osm
1
210
re:Invent2022 前後の Amazon EventBridge のアップデートを踏まえつつ、情シスの仕事をより楽しくしたい話。 / EventBridge for Information Systems Department
_kensh
2
750
データ分析基盤の要件分析の話(202201_JEDAI)
yabooun
0
280
目指せCoverage100%! AutoScale環境におけるSavings Plans購入戦略 / JAWS-UG_SRE_Coverage
taishin
0
510
KyvernoとRed Hat ACMを用いたマルチクラスターの一元的なポリシー制御
ry
0
190
イ良い日ンマを作る(USBストレージ容量偽装の手法) / USB Storage Capacity Faking Techniques
shutingrz
0
220
Featured
See All Featured
Web Components: a chance to create the future
zenorocha
304
40k
Building Adaptive Systems
keathley
27
1.3k
Code Review Best Practice
trishagee
50
11k
Thoughts on Productivity
jonyablonski
49
2.7k
Practical Orchestrator
shlominoach
178
8.9k
Keith and Marios Guide to Fast Websites
keithpitt
407
21k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
349
27k
Six Lessons from altMBA
skipperchong
15
2.3k
Why You Should Never Use an ORM
jnunemaker
PRO
49
7.9k
Facilitating Awesome Meetings
lara
33
4.6k
Statistics for Hackers
jakevdp
785
210k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
6
840
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