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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
蒼時弦や
May 07, 2018
Technology
150
0
Share
2018 - How the Rubyist use Blockchain
The talks about ruby and blockchain in rubyelixirconftw.
蒼時弦や
May 07, 2018
More Decks by 蒼時弦や
See All by 蒼時弦や
2024 - COSCUP - Clean Architecture in Rails
elct9620
2
200
2023 - RubyConfTW - Rethink Rails Architecture
elct9620
0
240
20230916 - DDDTW - 導入 Domain-Driven Design 的最佳時機
elct9620
0
470
2023 - WebConf - 選擇適合你的技能組合
elct9620
0
690
20230322 - Generative AI 小聚 ft. Happy Designer
elct9620
0
460
2022 - 默默會 - 重新學習 MVC 的 Model
elct9620
1
510
MOPCON 2022 - 從 Domain-Driven Design 看網站開發框架隱藏
elct9620
1
530
2022 - COSCUP - 我想慢慢寫程式該怎麼辦?
elct9620
0
290
2022 - COSCUP - 打造高速 Ruby 專案開發流程
elct9620
0
330
Other Decks in Technology
See All in Technology
AI時代から振り返るTerraform drift運用の歴史 / AI Age Reflections on the History of Terraform Drift Operations
aeonpeople
0
510
Python開発環境にハーネス適用を検討する
yuuka51
1
540
Geek Woman の育ち方 〜コミュニティとAIと〜
chicaco
0
430
RubyでRuby拡張を書いたらRubyより35倍速になったってどういうこと??
kazuho
3
650
oracle-to-databricks-migration-with-llm-and-dbt
casek
0
280
TypeScript で Platform SDK を作る技術
toiroakr
1
320
はじめてのAI-DLC
yoshidashingo
2
580
エンジニアは生成AIと どのように向き合うべきか? ことばの意味という観点から
verypluming
3
250
checker.tsにチキンレースを仕掛けてみた:型エラー(TS2589)が発生する境界線を求めて
hal_spidernight
1
210
【禁断】Obsidianの第二の脳に「知の巨人」と呼ばれた師匠の脳をロードしてみた
nagatsu
0
6.9k
権限管理設計を完全に理解した
rsugi
2
220
シンデレラなんかになりたくない!ガラスの靴が割れた時代にどう歩く?
nomizone
0
210
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Making the Leap to Tech Lead
cromwellryan
135
9.8k
Navigating Team Friction
lara
192
16k
Mobile First: as difficult as doing things right
swwweet
225
10k
How to Think Like a Performance Engineer
csswizardry
28
2.6k
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
190
Thoughts on Productivity
jonyablonski
76
5.2k
The SEO identity crisis: Don't let AI make you average
varn
0
470
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