#######
################
####################
########### #########
######### #########
####### ######### #########
######### ######### ##########
########## ######## ####################
########## ######### #########################
################### ############################
################# ########## ########
############## ### ########
############ #########
########## ##########
######## ###########
### ############
##############
#################
##############
#########
Unlock the potential of decentralized application development on Vechain with our X-App template for VeBetterDAO. Designed for the Vechain Thor blockchain, this template integrates cutting-edge technologies such as React, TypeScript, Hardhat, and Express, ensuring a seamless and efficient DApp development experience. π
Read more about the implementation and key features of this template in our Developer Docs.
This template uses the VeBetterDAO ecosystem to distribute rewards to users. To learn more about VeBetterDAO, visit our documentation.
When using the solo node you can import the following mnemonic into your wallet and have access to 10 pre-funded accounts:
denial kitchen pet squirrel other broom bar gas better priority spoil cross
Ensure your development environment is set up with the following:
- Node.js (v18 or later): Download here π₯
- Yarn: Install here π§Ά
- Docker (for containerization): Get Docker π³
- Hardhat (for smart contracts): Getting Started with Hardhat βοΈ
A blazing-fast React application powered by Vite:
- Vechain dapp-kit: Streamline wallet connections and interactions. Learn more
An Express server crafted with TypeScript for robust API development:
- Vechain SDK: Seamlessly fetch and perform transactions with the VechainThor blockchain. Learn more
- OpenAI GPT-Vision-Preview: Integrate image analysis capabilities. Explore here
Smart contracts in Solidity, managed with Hardhat for deployment on the Vechain Thor network.
Shared configurations and utility functions to unify and simplify your development process.
Configure your environment variables for seamless integration:
Place your .env
files in apps/frontend
:
- VITE_RECAPTCHA_V3_SITE_KEY: Request your RecaptchaV3 site keys
Store your environment-specific .env
files in apps/backend
. .env.development.local
& .env.production.local
allow for custom environment variables based on the environment:
- OPENAI_API_KEY: Get your GPT-4 OpenAI key (Enable GPT-4 here)
- RECAPTCHA_SECRET_KEY: Request your RecaptchaV3 site keys
Manage deployment parameters and network configurations in hardhat.config.js
under apps/contracts
:
- MNEMONIC: Mnemonic of the deploying wallet
Clone the repository and install dependencies with ease:
yarn install # Run this at the root level of the project
To distribute rewards this contract necesitates of a valid APP_ID provided by VeBetterDAO when joining the ecosystem. In testnet you can generate the APP_ID by using the VeBetterDAO sandbox. This contract can be initially deployed without this information and DEFAULT_ADMIN_ROLE can update it later through {EcoEarn-setAppId}.
This contract must me set as a rewardDistributor
inside the X2EarnApps contract to be able to send rewards to users and withdraw.
Deploy your contracts effortlessly on either the Testnet or Solo networks.
If you are deploying on the Testnet, ensure you have the correct addresses in the config-contracts
package (generated on the VeBetterDAO sandbox).
When deploying on the SOLO network the script will deploy for you the mocked VeBetterDAO contracts and generate an APP_ID.
yarn contracts:deploy:solo
yarn contracts:deploy:testnet
Run the Frontend and Backend, connected to the Solo network and pointing to your deployed contracts. Ensure all environment variables are properly configured:
yarn dev
Read the VeBetterDAO documentation to learn how to set up rewards for your users and use the Testnet environment.
Test environment: https://dev.testnet.governance.vebetterdao.org/
Thanks to the test environment you will be able to mint and deposit B3TR tokens int the rewards pool that you will use to distribute rewards to users.
Now you just need to trigger cycles and set amount of rewards per cycle on your EcoEarn contract.
-
Go to our online inspector app that you can use to interact with your contracts. Be sure to select the correct network (Testnet).
-
Add the
EcoEarn
contract to the inspector app. Get the address fromconfig-contracts
package and the ABI from theapps/contracts/artifacts/contracts/EcoEarn.sol/EcoEarn.json
file.
Since the Solo network is a local network with mocked VeBetterDAO contracts you can use the following steps to set up available rewards to distribute to users:
- Ensure you are using a wallet with imported pre-funded accounts mnemonic into your wallet. Mnemoninc:
denial kitchen pet squirrel other broom bar gas better priority spoil cross
- Copy the
APP_ID
generated by thecontracts:deploy:solo
script and logged in the console. - Run
devpal
, a frontend tool to interact with your contracts:
npx [email protected] https://localhost:8669
- Open the
Inspector
tab and perform the following actions: - Add the B3TR_Mock contract (get the address from the console logs and ABI from the
apps/contracts/artifacts/contracts/mock/B3TR_Mock.sol/B3TR_Mock.json
file) - Add the X2EarnRewardsPool contract (get the address from the console logs and ABI from the
apps/contracts/artifacts/contracts/mock/X2EarnRewardsPoolMock.sol/X2EarnRewardsPoolMock.json
file) - You should now have the following setup:
- To recharge the rewards pool you will need to mint some mocked B3TR tokens, then deposit them into the rewards pool. Perform the following actions:
- Now you just need to set how many rewards you want to distribute per cycle and trigger the start of the cycle
-
Add the
EcoEarn
contract to the inspector app. Get the address fromconfig-contracts
package and the ABI from theapps/contracts/artifacts/contracts/EcoEarn.sol/EcoEarn.json
file.
NB: Values are in wei, use this tool to convert to VET: https://eth-converter.com/
This template serves as a foundational starting point and should be thoroughly reviewed and customized to suit your projectβs specific requirements. Pay special attention to configurations, security settings, and environment variables to ensure a secure and efficient deployment.
Embrace the power of VeBetterDAO's X-Apps template and transform your DApp development experience. Happy coding! π