スマートコントラクトのソースコードです.
- デプロイはHub.jsから行ってください.他のコントラクトはHubコントラクトのアドレスを参照して初期化されます.
- Liquidは特別にVotingも参照するので,注意してください.
- Hub以外の各コントラクトはフィールドでHubコントラクトのアドレスを持っているので,Hubコントラクトデプロイ後に書き換えてください.初期段階では,AWSにデプロイされている環境を再現しているので注意してください.
iwallet compile <<contract_name>>.js
とすることでabiファイルが生成されます.
iwallet --gas_limit 4000000 --account <<account_name>> publish <<contract_name>>.js <<contract_name>>.js.abi
でコントラクトのデプロイを行ってください.
-
call.jsは実際にコントラクト呼び出しをするものです.以下のaccount.jsonとcname.json,src/のabiファイルなどを参照します.
-
cname.jsonはコントラクトのアドレスの参照に使います.
-
account.jsonはアカウントのIDと秘密鍵を紐付けるのに使います.
-
getKey.jsはHubコントラクトで登録されているテーブルのキーを計算するときに使います.Hubコントラクトでは
sha3(JSON.stringify({ subject: subjectName }))
といった形式で値を保存しています.このgetKey.jsはnode getKey.js <<subject or listeners or event>> <<valueName>>
で利用できます.
node call.js <<account_id>> <<contract_name>>
## 以下はコンソールに従って入力してください.
kunroku: call$ node call.js admin Membership
[selection]
can_update issue
action? issue
[args length require: 2]
arg 0? kosamit
arg 1? kosamit
kunroku: call$ node call.js kunroku Project
[selection]
can_update notify createProject join
action? createProject
arg 0? tproj01
arg 1? kunroku
arg 2? ["kosamit"]
arg 3? {"minSupportRate":50,"minVotingRate":80}
kunroku: call$ node call.js kosamit Project
[selection]
can_update notify createProject join
action? join
[args length require: 2]
arg 0? tproj01
arg 1? kosamit
kunroku: call$ node call.js kosamit Voting
[selection]
can_update notify addAlgo create executionCreate aggregate execute
action? create
[args length require: 6]
arg 0? tproj01
arg 1? kosamit
arg 2? liquid
arg 3? test
arg 4? 1578109921000000000
arg 5? ["abc","def","ghi"]
kunroku: call$ node call.js kosamit LiquidDemocracy
[selection]
can_update create vote delegate accept aggregate resultOf cancel
action? vote
[args length require: 3]
arg 0? Gi6dUNCnRWS6W6kRC1JzDxUfZNuFt5sZtMMYiZ6XqprN
arg 1? kosamit
arg 2? abc
kunroku: call$ node call.js kunroku LiquidDemocracy
[selection]
can_update create vote delegate accept aggregate resultOf cancel
action? delegate
[args length require: 3]
arg 0? Gi6dUNCnRWS6W6kRC1JzDxUfZNuFt5sZtMMYiZ6XqprN
arg 1? kunroku
arg 2? kosamit
kunroku: call$ node call.js kosamit LiquidDemocracy
[selection]
can_update create vote delegate accept aggregate resultOf cancel
action? accept
[args length require: 2]
arg 0? Gi6dUNCnRWS6W6kRC1JzDxUfZNuFt5sZtMMYiZ6XqprN
arg 1? kosamit
kunroku: call$ node call.js kosamit Voting
[selection]
can_update notify addAlgo create executionCreate aggregate execute
action? aggregate
[args length require: 2]
arg 0? tproj01
arg 1? Gi6dUNCnRWS6W6kRC1JzDxUfZNuFt5sZtMMYiZ6XqprN
## トランザクションのreceiptとreturnsに結果がある
## 中略 ##
receipts:
[ { func_name:
'ContractGiu8ZfUdtmjAVbnNXxarYHvjLstDaV26FQdj6SZhn8ff/aggregate',
content:
'{"result":["abc"],"info":{"rule":{"minSupportRate":"0","minVotingRate":"0.8"},"member":["kunroku","kosamit"],"choices":["abc","def","ghi"],"vote":{"kosamit":0,"kunroku":0},"delegate":{"kunroku":"kosamit"}}}' } ] }
return: ["abc"]
kunroku: call$ node call.js kunroku Voting
[selection]
can_update notify addAlgo create executionCreate aggregate execute
action? executionCreate
[args length require: 7]
arg 0? tproj01
arg 1? kunroku
arg 2? liquid
arg 3? oka
arg 4? 1578114620000000000
arg 5? invite
arg 6? thin9rypto
kunroku: call$ node call.js kosamit LiquidDemocracy
[selection]
can_update create vote delegate accept aggregate resultOf cancel
action? vote
[args length require: 3]
arg 0? 8AXD5ARvkgsoRcMm7yVMuX8H8yi5Jkb81UPkiX1Vuf1E
arg 1? kosamit
arg 2? yes
kunroku: call$ node call.js kunroku LiquidDemocracy
[selection]
can_update create vote delegate accept aggregate resultOf cancel
action? vote
[args length require: 3]
arg 0? 8AXD5ARvkgsoRcMm7yVMuX8H8yi5Jkb81UPkiX1Vuf1E
arg 1? kunroku
arg 2? yes
kunroku: call$ node call.js kunroku Voting
[selection]
can_update notify addAlgo create executionCreate aggregate execute
action? aggregate
[args length require: 2]
arg 0? tproj01
arg 1? 8AXD5ARvkgsoRcMm7yVMuX8H8yi5Jkb81UPkiX1Vuf1E
kunroku: call$ node call.js kosamit Voting
[selection]
can_update notify addAlgo create executionCreate aggregate execute
action? execute
[args length require: 2]
arg 0? tproj01
arg 1? 8AXD5ARvkgsoRcMm7yVMuX8H8yi5Jkb81UPkiX1Vuf1E
kunroku: call$ node call.js thin9rypto Project
[selection]
can_update notify createProject join
action? join
[args length require: 2]
arg 0? tproj01
arg 1? thin9rypto
kunroku: call$ node call.js kunroku Voting
[selection]
can_update notify addAlgo create executionCreate aggregate execute
action? executionCreate
[args length require: 7]
arg 0? tproj01
arg 1? kunroku
arg 2? liquid
arg 3? kaisan
arg 4? 1578115677000000000
arg 5? dissolution
arg 6? {}
## 中略
kunroku: call$ node call.js kunroku LiquidDemocracy
[selection]
can_update create vote delegate accept aggregate resultOf cancel
action? vote
[args length require: 3]
arg 0? WffodFmDpTHibjJ4GQDvL83XZuEBbUSbDwfNyiPQqWd
arg 1? kunroku
arg 2? yes
## 中略
kunroku: call$ node call.js thin9rypto LiquidDemocracy
[selection]
can_update create vote delegate accept aggregate resultOf cancel
action? vote
[args length require: 3]
arg 0? WffodFmDpTHibjJ4GQDvL83XZuEBbUSbDwfNyiPQqWd
arg 1? thin9rypto
arg 2? no
## 中略
kunroku: call$ node call.js kosamit LiquidDemocracy
[selection]
can_update create vote delegate accept aggregate resultOf cancel
action? vote
[args length require: 3]
arg 0? WffodFmDpTHibjJ4GQDvL83XZuEBbUSbDwfNyiPQqWd
arg 1? kosamit
arg 2? yes
## 中略
kunroku: call$ node call.js kunroku Voting
[selection]
can_update notify addAlgo create executionCreate aggregate execute
action? aggregate
[args length require: 2]
arg 0? tproj01
arg 1? WffodFmDpTHibjJ4GQDvL83XZuEBbUSbDwfNyiPQqWd
## 中略
kunroku: call$ node call.js kunroku Voting
[selection]
can_update notify addAlgo create executionCreate aggregate execute
action? execute
[args length require: 2]
arg 0? tproj01
arg 1? WffodFmDpTHibjJ4GQDvL83XZuEBbUSbDwfNyiPQqWd