Randgen Hub Voter CLI & SDK
Mind Network Randgen Hub Voter CLI & SDK
A TypeScript-based Command Line Interface (CLI) and SDK to interact with the Randgen Hub on the Mind Network. This tool provides functionalities such as voter registration, reward checking, encryption, and anonymous voting powered by Fully Homomorphic Encryption (FHE). The hub is live and accessible at Randgen Hub.
Features
Voter Registration: Register your hot wallet as a voter in the Randgen Hub.
Reward Checking: Check voting rewards associated with your hot and cold wallets.
Anonymous Voting: Perform one-time or continuous voting in eligible rounds, with anonymity guaranteed by FHE.
Fully Homomorphic Encryption (FHE): Leverage FHE for secure and privacy-preserving voting.
Encryption: Encrypt data using the FHE key set.
Vote Submission: Submit encrypted votes to the Randgen Hub.
SDK for Programmatic Usage: Use the SDK to integrate functionalities into your own projects.
Installation
Prerequisites
Node.js (version 20 or later)
npm (Node Package Manager)
Steps
Clone the repository
Navigate to the project directory
Install dependencies:
Build the project:
Run the CLI:
CLI Usage
The CLI provides various commands for interacting with the Randgen Hub. Below is a list of available commands:
register-voter
Registers the hot wallet as a voter in the Randgen Hub.
Arguments:
hotWalletPrivateKey
(optional): Private key of the hot wallet used for voting.coldWalletAddress
(optional): Cold wallet address to receive voting rewards.
check-voting-reward
Checks the voting rewards for the hot and cold wallets.
Options:
--hot-wallet-private-key
: Private key of the hot wallet.--cold-wallet-address
: Address of the cold wallet.
print-fhe-keyset
Fetches and displays the Fully Homomorphic Encryption (FHE) key set.
encrypt
Encrypts a given number using FHE.
Arguments:
number
: The number to encrypt.
submit-vote
Submits a vote using an encrypted ciphertext URL.
Arguments:
ciphertextUrl
: The URL of the encrypted vote.hotWalletPrivateKey
(optional): Private key of the hot wallet used for voting.
vote-once
Performs a single voting action in the Randgen Hub.
Arguments:
hotWalletPrivateKey
(optional): Private key of the hot wallet used for voting.
vote-nonstop
Continuously votes in every eligible round in the Randgen Hub.
Arguments:
hotWalletPrivateKey
(optional): Private key of the hot wallet used for voting.
Using as an SDK
You can integrate the project programmatically into your TypeScript or JavaScript projects by using the SDK.
Installation
Install the SDK using npm:
Exported Functions
The following functions are available for import:
registerVoter
: Register a voter in the Randgen Hub.checkHotWalletReward
: Check rewards associated with the hot wallet.checkColdWalletReward
: Check rewards associated with the cold wallet.fetchFheKeySet
: Fetch the FHE key set for encryption operations.encrypt
: Encrypt a number using the FHE key set.submitVote
: Submit a vote using an encrypted ciphertext.voteOnce
: Perform a one-time vote in the Randgen Hub.voteContinuously
: Continuously vote in all eligible rounds in the Randgen Hub.
Code Example
Here is an example of generating a random number, encrypting it, and submitting a vote.
Configuration
The CLI and SDK use a configuration file to store required settings. You can find the configuration in src/config.ts
.
Environment Variables
Configuration values like hotWalletPrivateKey
can also be provided as environment variables:
Refer to src/config.ts
for more configuration options.
Configuration Priorities
Command parameters > environment variables > config.ts
Development
Scripts
The following scripts are available:
npm run build
: Compiles the TypeScript code into JavaScript.npm run cli
: Builds and runs the CLI tool.npm run abi
: Generates TypeScript bindings for smart contract ABIs usingtypechain
.
License
This project is licensed under the MIT License.
Last updated