[學習筆記] 智能合約 20190423 by deanliu

View this thread on steempeak.com
· @deanliu ·
$18.14
[學習筆記] 智能合約 20190423
![](https://steemitimages.com/DQmebRJap3xUvmsBNapMqb528wxhvYPiDzbeH8gYdm6oTEA/image.png)
<sub>*source: http://ggllaw.net/areas-of-practice/*</sub>

最近,因為某些因素,想要更進一步多了解智能合約的運行實際情況,想起往年的文章,回頭找出這兩篇合作文章 (由失聯已久的 @antonsteemit執筆)

[DA-ChainTalk #1 — State,從宏觀到微觀:以太坊如何將智能合約帶入區塊鏈世界](https://steemit.com/da-chaintalk/@deanliu/state)
[DA-ChainTalk #3 — 智能合約之前世今生](https://steemit.com/da-chaintalk/@deanliu/da-chaintalk-3)

再讀一次,才發現自己當時其實沒有完全吸收,事隔一年再看,還是頗有收穫。不過,這樣的理解程度,還不能滿足我的需求,所以,去找了一位作開發的朋友,問他一下,這是最快的方式。

果然,寫代碼的朋友,頭腦都蠻清楚的,他跟我聊了十多分鐘,我收穫蠻大的。如果要自己看書來理解,恐怕是非常困難的。


以下,我把我學習到的基本概念,整理出來。也可能因為我理解錯誤而有錯,有專業的讀者們,歡迎指正我,繼續教導我更多關於智能合約的知識吧!^^

關於智能合約(smart contracts)

* 智能合約,可以被視為在區塊鏈上執行的程式,但比起一般程式,智能合約所受到的制約更多,所能達成的功能也比較有限。

* 智能合約的佈署(deploy),是透過一個EOA帳戶來上傳區塊鏈,把compile過的Solidity原始碼,記錄到一個智能合約帳戶裡去。

* 每個智能合約內可以有各種寫好的functions以及variables,variables的state可以更新,但智能合約本身結構,在上傳後就是不可更改的。

* 智能合約的地址,就是其上傳的那一個區塊地址,後面呼叫此合約,就會到此一地址來取得執行代碼。

* 智能合約的執行是必須依靠外界的觸發,且其執行具有atomic的概念,亦即所有程式都在這一次執行完成,完成後的更新狀態,紀錄為transaction

* 每個Ethereum礦工執行的結果是否符合該合約應該有的結果,可以輕易由其他礦工驗證,正如比特幣區塊鏈上,交易的結果是否正確,可以輕易由後續礦工所驗證。

* 因此,智能合約無法做到諸如:每個週一定時,自動地,由帳戶A轉帳1 Ether到帳戶B,這樣的自動化程序。

如果大家有推薦什麼好的文章連結,可以深入淺出地解釋智能合約的運作(不能太淺,但也不能技術性),請多多推薦給我吧!

![danbo-2495978_1280.jpg](https://steemitimages.com/DQmPACz2EHrzRFo6hguBVa63YC49YLSkYYQqysKeNeGvtuo/danbo-2495978_1280.jpg)
<sub> Image Source: pixabay</sub>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 112 others
properties (23)
post_id73,565,327
authordeanliu
permlink20,190,423
categorycn
json_metadata{"tags":["cn","smart-contracts","ethereum","blockchain","cn-programming"],"users":["antonsteemit"],"image":["https:\/\/steemitimages.com\/DQmebRJap3xUvmsBNapMqb528wxhvYPiDzbeH8gYdm6oTEA\/image.png","https:\/\/steemitimages.com\/DQmPACz2EHrzRFo6hguBVa63YC49YLSkYYQqysKeNeGvtuo\/danbo-2495978_1280.jpg"],"links":["http:\/\/ggllaw.net\/areas-of-practice\/","https:\/\/steemit.com\/da-chaintalk\/@deanliu\/state","https:\/\/steemit.com\/da-chaintalk\/@deanliu\/da-chaintalk-3"],"app":"steemit\/0.1","format":"markdown"}
created2019-04-23 03:03:36
last_update2019-04-23 03:03:36
depth0
children6
net_rshares36,588,726,432,566
last_payout2019-04-30 03:03:36
cashout_time1969-12-31 23:59:59
total_payout_value13.914 SBD
curator_payout_value4.230 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length1,344
author_reputation726,291,750,173,620
root_title"[學習筆記] 智能合約 20190423"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (176)
@partiko ·
Thank you so much for participating in the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!
properties (22)
post_id73,568,575
authorpartiko
permlinkre-20190423-20190423t043059
categorycn
json_metadata{"app":"partiko"}
created2019-04-23 04:31:00
last_update2019-04-23 04:31:00
depth1
children0
net_rshares0
last_payout2019-04-30 04:31:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length213
author_reputation39,204,266,552,701
root_title"[學習筆記] 智能合約 20190423"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@icebing925 ·
突然想起去年跟着你的post学python,结果学到一半放弃了😂

Posted using [Partiko Android](https://partiko.app/referral/icebing925)
properties (22)
post_id73,580,739
authoricebing925
permlinkicebing925-re-deanliu-20190423-20190423t095622963z
categorycn
json_metadata{"app":"partiko","client":"android"}
created2019-04-23 09:56:24
last_update2019-04-23 09:56:24
depth1
children1
net_rshares0
last_payout2019-04-30 09:56:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length105
author_reputation2,973,947,745,234
root_title"[學習筆記] 智能合約 20190423"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@deanliu ·
呵呵,別提了,我自己都沒學好呢,現在全部都忘了.... >_<
properties (22)
post_id73,594,387
authordeanliu
permlinkre-icebing925-icebing925-re-deanliu-20190423-20190423t144722591z
categorycn
json_metadata{"tags":["cn"],"app":"steemit\/0.1"}
created2019-04-23 14:47:24
last_update2019-04-23 14:47:24
depth2
children0
net_rshares0
last_payout2019-04-30 14:47:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length31
author_reputation726,291,750,173,620
root_title"[學習筆記] 智能合約 20190423"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@steem-plus ·
SteemPlus upvote
Hi, @deanliu!

You just got a **16.91%** upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in [here](https://steemit.com/@steem-plus) to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.
properties (22)
post_id73,586,266
authorsteem-plus
permlink20190423---vote-steemplus
categorycn
json_metadata{}
created2019-04-23 12:02:30
last_update2019-04-23 12:02:30
depth1
children0
net_rshares0
last_payout2019-04-30 12:02:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length435
author_reputation247,995,867,762,997
root_title"[學習筆記] 智能合約 20190423"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@steem-ua ·
#### Hi @deanliu!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your **UA** account score is currently 5.861 which ranks you at **#402** across all Steem accounts.
Your rank has improved 16 places in the last three days (old rank 418).

In our last Algorithmic Curation Round, consisting of 227 contributions, your post is ranked at **#7**.
##### Evaluation of your UA score:

* You've built up a nice network.
* The readers appreciate your great work!
* Great user engagement! You rock!


**Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
properties (22)
post_id73,617,150
authorsteem-ua
permlinkre-20190423-20190424t000942z
categorycn
json_metadata{"app":"beem\/0.20.19"}
created2019-04-24 00:09:42
last_update2019-04-24 00:09:42
depth1
children0
net_rshares0
last_payout2019-05-01 00:09:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length628
author_reputation23,203,609,903,979
root_title"[學習筆記] 智能合約 20190423"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@dailychina ·
$0.08
恭喜你!您的这篇文章入选 @justyy 今日 (2019-04-24) 榜单 [【优秀的文章】](https://steemit.com/cn/@justyy/--daily-cn-updates-cncnpower-downyy2019-04-24), 回复本条评论24小时内领赏,点赞本评论将支持 @dailychina 并增加将来您的奖赏。
 @justyy 是CN区的见证人,[请支持他,给他投票](https://steemconnect.com/sign/account_witness_vote?approve=1&witness=justyy),感谢!

Congratulations! This post has been selected by @justyy as today's (2019-04-24)  [【Good Posts】](https://steemit.com/cn/@justyy/--daily-cn-updates-cncnpower-downyy2019-04-24), Steem On!  Reply to this message in 24 hours to get rewards. Upvote this comment to support the @dailychina and increase your future rewards! ^_^

[SteemIt 工具、API接口、机器人和教程](https://steemyy.com/steemit-tools/)
[SteemIt Tools, Bots, APIs and Tutorial](https://SteemYY.com)
*Join cnsteem Discord channel: *https://discord.gg/SnNaaYS
👍  , , , , , , , , , , ,
properties (23)
post_id73,635,044
authordailychina
permlinkre-20190423-20190424t080129
categorycn
json_metadata{}
created2019-04-24 08:01:30
last_update2019-04-24 08:01:30
depth1
children0
net_rshares158,113,784,429
last_payout2019-05-01 08:01:30
cashout_time1969-12-31 23:59:59
total_payout_value0.060 SBD
curator_payout_value0.018 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length791
author_reputation50,118,723,362,727
root_title"[學習筆記] 智能合約 20190423"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (12)