用智慧合約發錢 - 數位貨幣

By David
at 2019-06-30T04:04
at 2019-06-30T04:04
Table of Contents
就是說,如果要灑 ETH 給很多人
一筆一筆 tx 慢慢按實在是手會很痠
就算寫 JS 用 web3 批次送還是會浪費手續費
比較好的方式應該是用合約分錢
雖然發合約也要吃 gas,但邊際成本低很多
大概是發五筆會打平,以上會省
重點是不用一直點確認交易
這邊簡單講一下流程
首先需要有發錢用的合約
大概是這樣
https://github.com/artistic709/solidity_contracts/blob/master/SimpleTransferMultiple.sol
然後打開 Solidity IDE - Remix
http://remix.ethereum.org/#optimize=false&version=soljson-v0.4.24+commit.e67f0147.js
左上角新增一個合約,把程式碼貼進去
https://i.imgur.com/TOG9P55.png
編譯語言選 Solidity,然後 compile
https://i.imgur.com/RQcyFXl.png
再到執行區,切到 injected Web3,跟你的 MetaMask 連動
https://i.imgur.com/iQ6tTLA.png
Value 欄位輸入灑錢的"總量",單位可以改成 ether (=10^18 wei)
Deploy 參數填灑錢的地址陣列,格式是 ["0x1","0x2","0x3"]
https://i.imgur.com/LaWIzmU.png
最後按下黃色的 Deploy,會確認是否要發出交易
錢就會順利的平分到每一個地址了
我的觀察啦
--
一筆一筆 tx 慢慢按實在是手會很痠
就算寫 JS 用 web3 批次送還是會浪費手續費
比較好的方式應該是用合約分錢
雖然發合約也要吃 gas,但邊際成本低很多
大概是發五筆會打平,以上會省
重點是不用一直點確認交易
這邊簡單講一下流程
首先需要有發錢用的合約
大概是這樣
https://github.com/artistic709/solidity_contracts/blob/master/SimpleTransferMultiple.sol
然後打開 Solidity IDE - Remix
http://remix.ethereum.org/#optimize=false&version=soljson-v0.4.24+commit.e67f0147.js
左上角新增一個合約,把程式碼貼進去
https://i.imgur.com/TOG9P55.png
編譯語言選 Solidity,然後 compile
https://i.imgur.com/RQcyFXl.png
再到執行區,切到 injected Web3,跟你的 MetaMask 連動
https://i.imgur.com/iQ6tTLA.png
Value 欄位輸入灑錢的"總量",單位可以改成 ether (=10^18 wei)
Deploy 參數填灑錢的地址陣列,格式是 ["0x1","0x2","0x3"]
https://i.imgur.com/LaWIzmU.png
最後按下黃色的 Deploy,會確認是否要發出交易
錢就會順利的平分到每一個地址了
我的觀察啦
--
Tags:
數位貨幣
All Comments

By Genevieve
at 2019-07-04T15:45
at 2019-07-04T15:45

By Necoo
at 2019-07-07T19:16
at 2019-07-07T19:16

By Kama
at 2019-07-08T11:02
at 2019-07-08T11:02

By Edward Lewis
at 2019-07-12T12:47
at 2019-07-12T12:47

By Andrew
at 2019-07-16T21:30
at 2019-07-16T21:30

By Sierra Rose
at 2019-07-17T19:16
at 2019-07-17T19:16

By Daph Bay
at 2019-07-19T04:12
at 2019-07-19T04:12

By Xanthe
at 2019-07-20T03:43
at 2019-07-20T03:43

By Donna
at 2019-07-24T04:25
at 2019-07-24T04:25

By Joseph
at 2019-07-29T04:13
at 2019-07-29T04:13

By Rachel
at 2019-08-02T13:16
at 2019-08-02T13:16

By Olga
at 2019-08-04T15:37
at 2019-08-04T15:37

By Harry
at 2019-08-05T01:27
at 2019-08-05T01:27

By Joe
at 2019-08-06T21:12
at 2019-08-06T21:12

By Emily
at 2019-08-10T11:38
at 2019-08-10T11:38

By George
at 2019-08-11T20:07
at 2019-08-11T20:07

By Isla
at 2019-08-13T23:30
at 2019-08-13T23:30

By Annie
at 2019-08-18T22:11
at 2019-08-18T22:11

By Dorothy
at 2019-08-19T19:10
at 2019-08-19T19:10

By Quanna
at 2019-08-23T04:06
at 2019-08-23T04:06

By Regina
at 2019-08-24T17:15
at 2019-08-24T17:15
Related Posts
ETH還錢

By Skylar Davis
at 2019-06-30T03:00
at 2019-06-30T03:00
幣圈大型資金盤 Plustoken 疑似崩盤

By Charlie
at 2019-06-30T02:08
at 2019-06-30T02:08
Re: [心得]比特幣--下一個鬱金香泡沫?或是新時代

By Aaliyah
at 2019-06-29T22:34
at 2019-06-29T22:34
IOTA Coordicide介紹 第1章

By Zora
at 2019-06-29T22:09
at 2019-06-29T22:09
比特幣將漲到25萬美元!他自爆與阿根廷總

By Andy
at 2019-06-29T16:24
at 2019-06-29T16:24