-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
774bae9
commit 7af573d
Showing
17 changed files
with
379 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
SHELL := /bin/bash | ||
|
||
help: | ||
@egrep -h '\s#@\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?#@ "}; {printf "\033[36m %-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
# Thor solo | ||
solo-up: #@ Start Thor solo | ||
docker compose -f packages/contracts/docker-compose.yaml up -d --wait thor-solo | ||
solo-down: #@ Stop Thor solo | ||
docker compose -f packages/contracts/docker-compose.yaml down | ||
solo-clean: #@ Clean Thor solo | ||
docker compose -f packages/contracts/docker-compose.yaml down -v --remove-orphans | ||
|
||
# Database | ||
DB_COMMAND=docker compose -f packages/database/docker-compose-mongo.yaml | ||
DB_MAKE_KEY=mkdir -p packages/database/keys; openssl rand -base64 756 > packages/database/keys/keyfile; | ||
DB_REMOVE_KEY=rm -f -R packages/database/keys | ||
DB_SETUP_COMMAND=docker compose -f packages/database/docker-compose-mongo-setup.yaml | ||
|
||
db-all: #@ Remove, clean and start all the database. | ||
make db-down db-clean db-up db-setup | ||
db-up: #@ Start the database. | ||
$(DB_COMMAND) up -d --wait | ||
db-clean: #@ Clean all the database data | ||
$(DB_COMMAND) down -v --remove-orphans; | ||
db-down: #@ Stop the database. | ||
$(DB_COMMAND) down | ||
db-keyfile-create: #@ Generate the keyfile for the database. | ||
$(DB_MAKE_KEY) | ||
db-keyfile-remove: #@ Remove the keyfile for the database. | ||
$(DB_REMOVE_KEY) | ||
db-setup: #@ Setup the database. | ||
$(DB_SETUP_COMMAND) up --build; $(DB_SETUP_COMMAND) rm --force | ||
|
||
NAV_CONTRACTS=cd packages/contracts | ||
|
||
# Contracts | ||
contracts-compile: #@ Compile the contracts. | ||
$(NAV_CONTRACTS); yarn compile | ||
contracts-deploy: contracts-compile solo-up #@ Deploy the contracts. | ||
$(NAV_CONTRACTS); yarn deploy | ||
contracts-test: contracts-compile #@ Test the contracts. | ||
$(NAV_CONTRACTS); yarn test | ||
|
||
# Apps | ||
install: #@ Install the dependencies. | ||
yarn install | ||
build: install #@ Build the app. | ||
yarn build | ||
test: #@ Test the app. | ||
yarn test | ||
.PHONY:build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
# React Dapp Template 🚀 | ||
|
||
This is a simple template of a decentralized application (DApp) built with React, and Solidity. It is designed to help you kickstart your DApp development journey. | ||
|
||
This template creates a simple DApp that allows users to interact with an erc20 token contract called *Fiorino*. Users can send and receive tokens, and the contract owner can mint new tokens. | ||
|
||
## Requirements | ||
|
||
Ensure your development environment is set up with the following: | ||
|
||
- **Node.js (v18 or later):** [Download here](https://nodejs.org/en/download/package-manager) 📥 | ||
- **Yarn:** [Install here](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable) 🧶 | ||
- **Docker (for containerization):** [Get Docker](https://docs.docker.com/get-docker/) 🐳 | ||
- **Hardhat (for smart contracts):** [Getting Started with Hardhat](https://hardhat.org/hardhat-runner/docs/getting-started) ⛑️ | ||
|
||
## Project Structure | ||
|
||
### Frontend (apps/frontend) 🌐 | ||
|
||
A blazing-fast React application powered by Vite: | ||
|
||
- **Vechain dapp-kit:** Streamline wallet connections and interactions. [Learn more](https://docs.vechain.org/developer-resources/sdks-and-providers/dapp-kit) | ||
|
||
### Contracts (packages/contracts) 📜 | ||
|
||
Smart contract in Solidity, managed with Hardhat for deployment on the Vechain Thor network. | ||
|
||
### Packages 📦 | ||
|
||
Shared configurations and utility functions to unify and simplify your development process. | ||
|
||
### Getting Started | ||
|
||
Clone the repository and install dependencies with ease: | ||
|
||
```bash | ||
yarn # Run this at the root level of the project | ||
``` | ||
|
||
Place your `.env` files in the root folder, you can copy `.env.example` file and rename it to `.env` changing the values to your own: | ||
|
||
## Running on Solo Network Locally (docker needed!) 🔧 | ||
|
||
### Spin up the Solo Network in a docker container: | ||
|
||
```bash | ||
yarn solo-up | ||
``` | ||
|
||
### Run the frontend and deploy the contracts on the Local Solo Network (if not deployed yet) with a single command: | ||
|
||
```bash | ||
yarn dev | ||
``` | ||
|
||
You should see a log like this, that means the frontend is running: | ||
|
||
```bash | ||
frontend:dev: VITE v5.3.2 ready in 135 ms | ||
frontend:dev: | ||
frontend:dev: ➜ Local: http://localhost:5001/ | ||
frontend:dev: ➜ Network: http://192.168.1.26:5001/ | ||
frontend:dev: ➜ Network: http://192.168.64.1:5001/ | ||
frontend:dev: ➜ press h + enter to show help | ||
``` | ||
|
||
and then you see a log like this, that means the contracts are deployed: | ||
|
||
```bash | ||
@repo/contracts:check-contracts-deployment: ================ Contracts deployed in 0m 9s | ||
@repo/contracts:check-contracts-deployment: Contracts { fiorino: '0xE55842798426F155Ad7Ff6E9C93378690d1FF46a' } | ||
@repo/contracts:check-contracts-deployment: Contracts and libraries addresses saved to /path/apps/react-dapp-template/packages/contracts/deploy_output | ||
@repo/contracts:check-contracts-deployment: Total execution time: 0m 9s | ||
@repo/contracts:check-contracts-deployment: Deployment completed successfully! | ||
@repo/contracts:check-contracts-deployment: ================================================================================ | ||
@repo/contracts:check-contracts-deployment: Writing new config file to /path/apps/react-dapp-template/packages/config/local.ts | ||
``` | ||
or a log like this, that means the contracts are already deployed (if you run the `yarn dev` command again): | ||
```bash | ||
@repo/contracts:check-contracts-deployment: Checking contracts deployment on vechain_solo (http://localhost:8669)... | ||
@repo/contracts:check-contracts-deployment: fiorino contract already deployed | ||
``` | ||
### Redeploy the contracts: | ||
```bash | ||
yarn contracts:deploy | ||
``` | ||
or | ||
Put empty string in the `fiorinoContractAddress` in the `packages/config/local.ts` file: | ||
```typescript | ||
fiorinoContractAddress: "", | ||
``` | ||
and then run the `yarn dev` command again. | ||
### Spin down the Solo Network | ||
```bash | ||
yarn solo-down | ||
``` | ||
### Clean docker solo network | ||
```bash | ||
yarn solo-clean | ||
``` | ||
## Running on Testnet 🌐 | ||
### Deploy the contracts on the Testnet: | ||
```bash | ||
yarn contracts:deploy:testnet | ||
``` | ||
### Run the frontend to interact with the contracts on the Testnet: | ||
```bash | ||
yarn dev:testnet | ||
``` | ||
## Running on Mainnet 🌐 | ||
### Deploy the contracts on the Mainnet: | ||
```bash | ||
yarn contracts:deploy:mainnet | ||
``` | ||
### Run the frontend to interact with the contracts on the Mainnet: | ||
```bash | ||
yarn dev:mainnet | ||
``` | ||
## Disclaimer ⚠️ | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export type ContractsConfig = { | ||
VITE_APP_ENV: "local" | "e2e" | "solo-staging" | "testnet" | "mainnet"; | ||
VITE_APP_ENV: "local" | "e2e" | "testnet" | "mainnet"; | ||
CONTRACTS_ADMIN_ADDRESS: string; | ||
XAPP_BASE_URI: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,37 @@ | ||
import { AppConfig } from "."; | ||
const config: AppConfig = { | ||
environment: "solo-staging", | ||
basePath: "http://localhost:3000", | ||
fiorinoContractAddress: "0x9e993Ac115BF2AC3Dee79f7652E2289c55c9C176", | ||
nodeUrl: "http://localhost:8669", | ||
network: { | ||
id: "solo", | ||
name: "solo", | ||
type: "solo", | ||
defaultNet: true, | ||
urls: ["http://localhost:8669"], | ||
explorerUrl: "https://explore-testnet.vechain.org", | ||
blockTime: 10000, | ||
genesis: { | ||
number: 0, | ||
id: "0x00000000c05a20fbca2bf6ae3affba6af4a74b800b585bf7a4988aba7aea69f6", | ||
size: 170, | ||
parentID: | ||
"0xffffffff53616c757465202620526573706563742c20457468657265756d2100", | ||
timestamp: 1530316800, | ||
gasLimit: 10000000, | ||
beneficiary: "0x0000000000000000000000000000000000000000", | ||
gasUsed: 0, | ||
totalScore: 0, | ||
txsRoot: | ||
"0x45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0", | ||
txsFeatures: 0, | ||
stateRoot: | ||
"0x93de0ffb1f33bc0af053abc2a87c4af44594f5dcb1cb879dd823686a15d68550", | ||
receiptsRoot: | ||
"0x45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0", | ||
signer: "0x0000000000000000000000000000000000000000", | ||
isTrunk: true, | ||
transactions: [], | ||
}, | ||
import { AppConfig } from "." | ||
const config: AppConfig = { | ||
"environment": "local", | ||
"basePath": "http://localhost:3000", | ||
"nodeUrl": "http://localhost:8669", | ||
"network": { | ||
"id": "solo", | ||
"name": "solo", | ||
"type": "solo", | ||
"defaultNet": true, | ||
"urls": [ | ||
"http://localhost:8669" | ||
], | ||
"explorerUrl": "https://explore-testnet.vechain.org", | ||
"blockTime": 10000, | ||
"genesis": { | ||
"number": 0, | ||
"id": "0x00000000c05a20fbca2bf6ae3affba6af4a74b800b585bf7a4988aba7aea69f6", | ||
"size": 170, | ||
"parentID": "0xffffffff53616c757465202620526573706563742c20457468657265756d2100", | ||
"timestamp": 1530316800, | ||
"gasLimit": 10000000, | ||
"beneficiary": "0x0000000000000000000000000000000000000000", | ||
"gasUsed": 0, | ||
"totalScore": 0, | ||
"txsRoot": "0x45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0", | ||
"txsFeatures": 0, | ||
"stateRoot": "0x93de0ffb1f33bc0af053abc2a87c4af44594f5dcb1cb879dd823686a15d68550", | ||
"receiptsRoot": "0x45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0", | ||
"signer": "0x0000000000000000000000000000000000000000", | ||
"isTrunk": true, | ||
"transactions": [] | ||
} | ||
}, | ||
"fiorinoContractAddress": "0x5d4188A633E1E6F4c6a3846dEbaBaa730AF58e6A" | ||
}; | ||
export default config; | ||
export default config; |
Oops, something went wrong.