ICON Workshop — Voting DAPP

2infiniti
2infiniti
Nov 5, 2018 · 4 min read
$ git clone https://gitlab.com/ibriz/icon-polling.git

SCORE

config/tbears_cli_config_testnet.json
{
"uri": "https://bicon.net.solidwallet.io/api/v3",
"nid": "0x3",
"keyStore": null,
"from": "hxe9d75191906ccc604fc1e45a9f3c59fb856c215f",
"to": "cx0000000000000000000000000000000000000000",
"deploy": {
"stepLimit": "0x5a000000",
"contentType": "zip",
"mode": "install",
"scoreParams": {
}
},
"txresult": {},
"transfer": {}
}
$ tbears deploy polling -k keystores/keystore1.json -c config/tbears_cli_config_testnet.json# password p@ssword1
$ tbears txresult 0x3948fbf6ca67dd04801283c47123064e54d7324a358add345c8c4fd05fa1d385 -u https://bicon.net.solidwa
llet.io/api/v3
"scoreAddress": "cx4e739b203b92498b6b6fb6d205f1cb62a6d4f88d"
# webapp/main.py
default_score = "cx4e739b203b92498b6b6fb6d205f1cb62a6d4f88d"
# Last line
app.run(debug=True, host='localhost', port=5000)
$ python main.py
# Visit http://localhost:5000
# webapp/main.pywallets = {
'wallet1': KeyWallet.load("../keystores/keystore1.json", "p@ssword1"),
'wallet2': KeyWallet.load("../keystores/iconkeystore3", "@icon333"),
'wallet3': KeyWallet.load("../keystores/iconkeystore4", "@icon444"),
}
# testcmd/send.json
{
"jsonrpc": "2.0",
"method": "icx_sendTransaction",
"params": {
"version": "0x3",
"from": "hxe9d75191906ccc604fc1e45a9f3c59fb856c215f",
"value": "0x0",
"stepLimit": "0x200000",
"nid": "0x3",
"nonce": "0x2",
"to": "cx4e739b203b92498b6b6fb6d205f1cb62a6d4f88d",
"dataType": "call",
"data": {
"method": "vote",
"params": {
"_vote": "0x1"
}
}
},
"id": 1
}
$ tbears sendtx -k keystores/keystore1.json testcmdline/send.json -u https://bicon.net.solidwallet.io/api/v3
$ tbears txresult 0xad6e8058a8f992f6b7312848853437c9639280e436e5391dd6254d8593d637ec -u https://bicon.net.solidwallet.io/api/v3
# testcmdline/call.json
{
"jsonrpc": "2.0",
"method": "icx_call",
"params": {
"from": "hxe9d75191906ccc604fc1e45a9f3c59fb856c215f",
"to": "cx4e739b203b92498b6b6fb6d205f1cb62a6d4f88d",
"dataType": "call",
"data": {
"method": "get_vote_talley"
}
},
"id": 1
}
$ tbears call testcmdline/call.json -u https://bicon.net.solidwallet.io/api/v3
response : {
"jsonrpc": "2.0",
"result": {
"yes": "0x2",
"no": "0x1"
},
"id": 1
}

Web App



Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade