{"id":25115579,"url":"https://github.com/xrplwin/hook-simplevoting","last_synced_at":"2025-08-17T16:16:03.564Z","repository":{"id":274868906,"uuid":"924331345","full_name":"XRPLWin/hook-simplevoting","owner":"XRPLWin","description":"Simple Voting Contract Hook for Xahau Network","archived":false,"fork":false,"pushed_at":"2025-01-30T17:22:27.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-08T02:32:00.087Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/XRPLWin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-29T20:10:52.000Z","updated_at":"2025-01-31T22:26:35.000Z","dependencies_parsed_at":"2025-01-29T21:22:21.201Z","dependency_job_id":"f68cb0af-a405-43ad-a54c-7c1c3817b8d6","html_url":"https://github.com/XRPLWin/hook-simplevoting","commit_stats":null,"previous_names":["xrplwin/hook-simplevoting"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XRPLWin%2Fhook-simplevoting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XRPLWin%2Fhook-simplevoting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XRPLWin%2Fhook-simplevoting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XRPLWin%2Fhook-simplevoting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XRPLWin","download_url":"https://codeload.github.com/XRPLWin/hook-simplevoting/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246811064,"owners_count":20837745,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-08T02:29:53.132Z","updated_at":"2025-04-02T11:40:52.307Z","avatar_url":"https://github.com/XRPLWin.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Voting Contract Hook\nSimple Voting Contract Hook for Xahau Network\n\n## Installation\nHook is installed on one account, users send `Invoke` transaction to that account to vote for one of candidates.\n\nHookOn triggers: `ttINVOKE`\n\n## Setup\nTo add new candidate send `Invoke` transaction from account which have this hook installed (self).\n\n```\n{\n    \"TransactionType\": \"Invoke\",\n    \"Account\": \"rVotingaccount... (self)\",\n    \"HookParameters\": [\n      {\n        \"HookParameter\": {\n          \"HookParameterName\": \u003cuint8ToHex(0)\u003e,\n          \"HookParameterValue\": \u003cuint16ToHex(1)\u003e+\u003c(convertStringToHex('Name of candidate 1').padEnd(64,'0'))\u003e\n        }\n      },\n      {\n        \"HookParameter\": {\n          \"HookParameterName\": \u003cuint8ToHex(1)\u003e,\n          \"HookParameterValue\": \u003cuint16ToHex(6)\u003e+\u003c(convertStringToHex('Name of candidate 6').padEnd(64,'0'))\u003e\n        }\n      },\n      ...\n...\n```\nIn each transaction HookParameterName starts with 0, this ensures hook treats parameters as array-like structure. \nHookParameterValue is coumpound data of UInt16 number in HEX - that is candidate ID, followed by candidate title (32 chars max).  \nOnce executed, hookstate row will be added.\n\n\n## Voting\nTo vote on existing candidate ID, send Invoke transaction to account which have this hook installed.\n```\n{\n    \"TransactionType\": \"Invoke\",\n    \"Account\": \"rVoter...\",\n    \"HookParameters\": [\n      {\n        \"HookParameter\": {\n          \"HookParameterName\": \u003cconvertStringToHex(\"KEY\")\u003e,\n          \"HookParameterValue\": \u003cuint16ToHex(1)\u003e\n        }\n      },\n    ],\n    \"Destination\": \"rVotingaccount...\",\n```\nHookParameterName - always \"KEY\"\nHookParameterValue - candidate ID in this sample \"Name of candidate 1\"\n\n## ABI for hookstates\n```JSON\n{ \n  \"name\": \"votinghook\",\n  \"hook_account\": \"\",\n  \"hook_namespace_id\": \"\",\n  \"hook_definition\": {\n    \"name\": \"votinghook\",\n    \"description\": \"votinghook\",\n    \"hook_hash\": \"\",\n    \"version\": [],\n    \"hook_states\": {\n      \"name\": \"votinghook\",\n      \"description\": \"votinghook\",\n      \"fields\": [\n        {\n          \"name\": \"Candidates\",\n          \"hookstate_key\": [\n            {\n              \"type\": \"Null\",\n              \"name\": \"padding\",\n              \"byte_length\": 31,\n              \"exclude\": true\n            },\n            {\n              \"type\": \"UInt8\",\n              \"name\": \"ID\",\n              \"exclude\": false\n            }\n          ],\n          \"hookstate_data\": [\n            {\n              \"type\": \"VarString\",\n              \"name\": \"Candidate name\",\n              \"byte_length\":32,\n              \"exclude\":false\n            },\n            {\n              \"type\":\"UInt16\",\n              \"name\":\"Number of votes\"\n            }\n          ]\n        },\n        {\n          \"name\": \"Votes\",\n          \"hookstate_key\": [\n            {\n              \"type\": \"Null\",\n              \"name\": \"padding\",\n              \"byte_length\": 12,\n              \"exclude\": true\n            },\n            {\n              \"type\": \"AccountID\",\n              \"name\": \"Voter\"\n            }\n          ],\n          \"hookstate_data\": [\n            {\n              \"type\": \"VarString\",\n              \"name\": \"Candidate name\",\n              \"byte_length\":32,\n              \"exclude\":false\n            }\n          ]\n        }\n      ]\n    }\n  }\n}\n```\n\nCredit for creating hook:  [@tequdev](https://github.com/tequdev)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxrplwin%2Fhook-simplevoting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxrplwin%2Fhook-simplevoting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxrplwin%2Fhook-simplevoting/lists"}