-
Notifications
You must be signed in to change notification settings - Fork 13
BaerChain vote transaction
- 4.1 Query canditate set
- 4.2 Query the specific situlation of voting
- 4.3 Query the number of votes obtained by candidates
- 4.4 Query voting count
{
"from":"e523e7c59a0725afd08bc9751c89eed6f8e16dec",
"to":"0x00000000000000000000000000000000766f7465",
"value":"0x0",
"data":[
{
"type":1,
"m_from":"e523e7c59a0725afd08bc9751c89eed6f8e16dec",
"m_to":"0x4eb60bfab454b5aaece4e8759e62ed36266fde39",
"m_vote_type":5,
"m_vote_numbers":"0xa"
}
],
"chainId":"0x1",
"nonce":"0x0",
"gas":"0x13880",
"gasPrice":"0x5"
}- Viewable code for json assembly
- params describution
from : Type string, vote transaction initiation address
to : Type string, fixed address, cannot be changed
value : Type stirng, default to "0x0"
data : voting transaction data, array structure
> type : Type int, transaction indentification number, type fixed to 1, representing vote transactions
> m_from : Type string, vote transaction initiation address, same as "from" address
> m_to : Type string, address to accept vote transaction
> m_vote_type : Type 为int,Note:
(1)Optinol values(1:buy tickets 2:sell tickets 5:voting tickets 6:cancel voting tickets)
(2) The case type is 5, expressed as a designated address vote
(3) Note: Before voting operation, it is necessary(1:buy tickets) to ensure that you have tickets to vote
(4) Note: The address fo m_from and to should be the same when buying and seling tickets
> m_vote_numbers : Type string, number of tickets
Note: The number of tickets is transferred in hexadecimal system, that is , if you buy 10 tickets, you need to pass "0xa"
chainId : Type string, hexadecimal, chain ID, must be the same as chainid of chain genesis
nonce : Type string, hexadecimal, nonce value, after each execution +1
gas : Type string,hexadecimal, gas integer provided for transaction execution
gasPrice : Type string, hexadecimal, gasPrice integer for each gas payment
- Note: When to fills in other addresses and data is not empty, the default to is the contract address to be invoked, and the value of value (value if it has value) transferred from the to to is generally prohibited.
2.Voting transaction statement Return directory
-
Users can buy ballots by spending BRC, but only the address in the candidate pool can be voted on.
-
Query candidate set
-
command
curl -d '{"jsonrpc":"2.0","id":9,"method":"brc_getElector","params":["latest"]}' http://10.0.6.122:33050 -
Returning to the results, as follows, shows that six candidates can vote at this time.
{ "id": 9, "jsonrpc": "2.0", "result": { "electors": [{ "address": "0xcccc7a30bf688c060524dfd759fe2627ed3387bc", "vote_num": "0x0" }, { "address": "0xdb1874c67cf3628690c795f0553e0e2904b02ffd", "vote_num": "0x0" }, { "address": "0xc3eb4d16a99e0a04de3242729a759a45809d2628", "vote_num": "0x0" }, { "address": "0x02b3d7c2f9f53f5bbcb3794da5282566f5632b46", "vote_num": "0x0" }, { "address": "0xd15c70cb560cea42995c9f52858778aa8b08c1c1", "vote_num": "0x0" }, { "address": "0x6e8c3d142894db1e06a026497f6b506c49069908", "vote_num": "0x0" }] } }
-
3. Voting transaction process describution Return directory
-
According to the actual situation, they should be executed separately.:(1:buy tickets, 2:sell tickets, 5:voting tickets , 6:cancel vote tickets)
-
command
./cmdWallet -j ./vote_data.json -s 10.0.6.122:33050 -
cmdWallet execution file acquisition
cd cpp-lsac/build : entry directory cmake .. : command make : command cd cpp-lsac/build/wallet/cmdWallet : In this directory, you can find the cmdWallet execution file that you just compiled. -
If execution 1: Buy 10 tickets
You can use the brc_getBalance interface to query the number of tickets you own after buying tickets. The following are all available with this interface
curl -d '{"jsonrpc":"2.0","id":9,"method":"brc_getBalance","params":["6e8c3d142894db1e06a026497f6b506c49069908","latest"]}' 10.0.6.122:33050
- results
{ "id": 22, "jsonrpc": "2.0", "result": { "Address": "0x6e8c3d142894db1e06a026497f6b506c49069908", "BRC": "0xa4d87b3d34e00", (Represents the number of votes you have, which is 10 votes at this time, and if there are no votes, it is "0x0".) "FBRC": "0x0", "FBalance": "0x2710", "balance": "0xa4d88ddd452c0", "ballot": "0xa", "cookieinsummury": "0x0", "nonce": "0x2", "poll": "0x0",("0x0" means 0 votes) "vote": null } }
If execution 2: Sell 1 tickets
results
{ "id": 22, "jsonrpc": "2.0", "result": { "Address": "0x6e8c3d142894db1e06a026497f6b506c49069908", "BRC": "0x997a1b0ac38df", "FBRC": "0x0", "FBalance": "0x0", "balance": "0xa4d88ddcdc3ec", "ballot": "0x9",(indicate the number of tickets you have. at this time, it is 9 tickes, indicating that you have sold 1 tickets "cookieinsummury": "0x0", "nonce": "0x3", "poll": "0x0",("0x0 means 0 ticket") "vote": null }
5:voting 3 tickets
if execution 5: voting 3 tickets
In this test 0x6e8c3d142894db1e06a026497f6b506c49069908 is candidate, vote yourself in this test
results
{ "id": 22, "jsonrpc": "2.0", "result": { "Address": "0x6e8c3d142894db1e06a026497f6b506c49069908", "BRC": "0x997a1b0ac38df", "FBRC": "0x0", "FBalance": "0x0", "balance": "0xa4d88ddcb885c", "ballot": "0x6", (Represents the number of tickets you have, at this time 6 tickets, indicating 3 tickets cast) "cookieinsummury": "0x0", "nonce": "0x4", "poll": "0x3",(The numbers votes obtained, at this time, is 3, indicating that three votes were voted on) "vote":[{ "Address": "0x6e8c3d142894db1e06a026497f6b506c49069908", (vote address) "vote_num": "0x3" (Number of votes cast at that address) }] } }3.4 cancel vote tickets Return directory
- if execution 6, cancel vote 1 tickets
- results
{ "id": 22, "jsonrpc": "2.0", "result": { "Address": "0x6e8c3d142894db1e06a026497f6b506c49069908", "BRC": "0x997a1b0ac38df", "FBRC": "0x0", "FBalance": "0x0", "balance": "0xa4d88ddc352a4", "ballot": "0x7",(indicate the number of votes you have, 7 tickets at this time, indicatin the cancel of 1 ticket) "cookieinsummury": "0x0", "nonce": "0x8", "poll": "0x2",(The number of tickets obtained, at this time, is 2, indicating that 2 tickets were cast) "vote": [{ (Record which address to vote for youeself) "Address": "0x6e8c3d142894db1e06a026497f6b506c49069908",(Voting address) "vote_num": "0x2" (Number of votes cast at that address) }] } }
4. Vote process query description Return directory
-
comand
- After doing this, query the candidate set again to see the changes
curl -d '{"jsonrpc":"2.0","id":9,"method":"brc_getElector","params":["latest"]}' http://10.0.6.122:33050 -
results
{ "id": 9, "jsonrpc": "2.0", "result": { "electors": [{ "address": "0xcccc7a30bf688c060524dfd759fe2627ed3387bc", "vote_num": "0x0" }, { "address": "0xdb1874c67cf3628690c795f0553e0e2904b02ffd", "vote_num": "0x0" }, { "address": "0xc3eb4d16a99e0a04de3242729a759a45809d2628", "vote_num": "0x0" }, { "address": "0x02b3d7c2f9f53f5bbcb3794da5282566f5632b46", "vote_num": "0x0" }, { "address": "0xd15c70cb560cea42995c9f52858778aa8b08c1c1", "vote_num": "0x0" }, { "address": "0x6e8c3d142894db1e06a026497f6b506c49069908", "vote_num": "0x2" (You can see that two tickets have been paid for the change of address at this time) }] } }
4.2 Query the specific situation of voting return directory
-
command
- Query the specific voting situation of an address
curl -d '{"jsonrpc":"2.0","id":9,"method":"brc_getVoted","params":["0x6e8c3d142894db1e06a026497f6b506c49069908","latest"]}' http://10.0.6.122:33050 -
results
{ "id": 9, "jsonrpc": "2.0", "result": { "total_voted_num": "0x3", "vote": [{ "address": "0x6e8c3d142894db1e06a026497f6b506c49069908", "voted_num": "0x2" }, { "address": "0xdb1874c67cf3628690c795f0553e0e2904b02ffd", "voted_num": "0x1" }] } }- Note : Address 0x6e8c3d142894db1e06a026497f6b506c49069908 give itself(0x6e8c3d142894db1e06a026497f6b506c49069908)voted 2 tickets, give address 0xdb1874c67cf3628690c795f0553e0e2904b02ffd voted 1 ticket
4.3 Query the number of votes obtained by candidates Return directory
-
command
- Query the number of votes obtained by the nominated candid
curl -d '{"jsonrpc":"2.0","id":9,"method":"brc_getObtainVote","params":["0x6e8c3d142894db1e06a026497f6b506c49069908","latest"]}' http://10.0.6.122:33050 -
results
{ "id": 9, "jsonrpc": "2.0", "result": { "addrsss": "0x6e8c3d142894db1e06a026497f6b506c49069908", "obtain_vote": "0x2" } }- Note : at this time, address 0x6e8c3d142894db1e06a026497f6b506c49069908 the total number of votes was 2
4.4 Query voting count Return directory
- command
curl -d '{"jsonrpc":"2.0","method":"brc_getBallot","params":["0x6e8c3d142894db1e06a026497f6b506c49069908", "latest"],"id":1}' http://10.0.6.122:33050
- results
{
"id": 1,
"jsonrpc": "2.0",
"result": "0x7" (indicates that the address now has 7 votes)
}