GLX DAO is a Decentralized Autonomous Organization that implements a governance token contract called GLX, which allows users to participate in voting on proposals to influence the decision-making process within the organization. This Readme provides a comprehensive guide on how to set up and run the GLX DAO application using TypeScript and Hardhat.
- Getting Started
- Hardhat Configuration
- GLX Token Contract
- Deployment
- Interacting with the GLX DAO
- Testing
- Additional Resources
To set up and run the GLX DAO application, ensure you have the following installed on your system:
-
Node.js: GLX DAO is built using TypeScript, so make sure you have Node.js installed. You can download it from the official website: https://nodejs.org/
-
Git: You will need Git installed to clone the GLX DAO repository.
Follow these steps to set up the GLX DAO application:
- Clone the Repository:
git clone <repository-url>
cd glx-dao
- Install Dependencies:
npm install
Hardhat is used as the development environment and build tool for the GLX DAO application. The configuration for Hardhat is defined in the hardhat.config.ts
file in the root directory.
The configuration specifies the solidity version, network settings, and other options for compiling, testing, and deploying contracts.
The GLX token contract is defined in the contracts/GLX.sol
file. This contract implements the functionality of an ERC-20 token with additional features for voting and delegation. Key functionalities of the GLX token contract include:
-
Token Name, Symbol, and Decimals: The GLX token adheres to the EIP-20 standard with a name, symbol, and decimal places.
-
Token Balances: The contract maintains the balance of tokens for each account.
-
Delegation: Token holders can delegate their voting power to another account to participate in governance.
-
Voting Power: The voting power of each account is determined based on the number of tokens they hold, with modifications using a StakeModifier contract.
-
Checkpoints: The contract keeps track of voting checkpoints for each account to enable voting snapshots.
-
Minting: The contract allows an admin address to mint additional tokens.
-
Cross-chain Bridge: The contract allows transferring tokens to a cross-chain bridge for compatibility with other blockchains.
To deploy the GLX token contract to a network, follow these steps:
-
Set up Infura: You will need an Infura project ID to connect to the desired Ethereum network (e.g., Goerli). Sign up for a free account on the Infura website and obtain the project ID.
-
Update
secrets.json
: Create asecrets.json
file in the root directory with your Infura project ID and a private key for an account on the desired network. -
Compile Contracts: Before deploying, compile the Solidity contracts using Hardhat:
npx hardhat compile
- Deploy the Contract: Use the
deployGLX.ts
script to deploy the GLX token contract to the desired network. Run:
npx hardhat run --network <network-name> scripts/deploy.ts
Replace <network-name>
with the name of the network you want to deploy to, such as goerli
, rinkeby
, or mainnet
.
To interact with the GLX DAO contract after deployment, you can use a wallet or a DApp that supports the Ethereum network you deployed to. Interactions with the contract include:
-
Transferring Tokens: Users can transfer GLX tokens to other accounts.
-
Delegation: Token holders can delegate their voting power to another address.
-
Voting: Delegators and token holders can vote on governance proposals.
-
View Voting Power: Users can check their current voting power.
Testing the GLX DAO contract is crucial to ensure its functionality and security. The test cases are defined in the test
directory using Hardhat's testing framework.
To run the tests, use the following command:
npx hardhat test --network <network-name>
Replace <network-name>
with the name of the network you want to test on.
For more information on Solidity, Hardhat, and Ethereum development, refer to the following resources:
-
Solidity Documentation: https://docs.soliditylang.org/
-
Hardhat Documentation: https://hardhat.org/getting-started/
-
Ethereum Development with Hardhat and Typescript: