Skip to content

Commit

Permalink
docs: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pierobassa committed Sep 24, 2023
1 parent 83a9f48 commit f6522b8
Showing 1 changed file with 147 additions and 22 deletions.
169 changes: 147 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,161 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
# DApp Documentation
## Requirements:
- Foundryup (https://book.getfoundry.sh/getting-started/installation)
- `.env.local` file correctly set with all required values from `.env.example`

## Getting Started
## Installation

First, run the development server:
```
yarn install
```

## Running the DApp

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
yarn run dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
# Foundry

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
## Test contracts

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
```
forge test # Displays a summary of passing / failing tests
```

The default behavior for forge test is to only display a summary of passing and failing tests. You can control this behavior by increasing the verbosity (using the -v flag). Each level of verbosity adds more information:

## Learn More
- Level 2 (-vv): Logs emitted during tests are also displayed. That includes assertion errors from tests, showing information such as expected vs actual.
- Level 3 (-vvv): Stack traces for failing tests are also displayed.
- Level 4 (-vvvv): Stack traces for all tests are displayed, and setup traces for failing tests are displayed.
- Level 5 (-vvvvv): Stack traces and setup traces are always displayed.

To learn more about Next.js, take a look at the following resources:
## Deploy contracts

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
First set your environment variables by creating `.env` file in `./forge` directory

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
```
cd forge
source .env # source environment variables
```

## Deploy on Vercel
### Deploy unverified contract

```
forge create --rpc-url $RPC_URL \
--private-key $PRIVATE_KEY \
src/RubyRingV1.sol:RubyRingV1
```

Get an `RPC_URL` from a Node Provider, e.g [Alchemy](https://dashboard.alchemy.com/)

### Deploy verified contract

```
forge create --rpc-url $RPC_URL \
--private-key $PRIVATE_KEY \
--etherscan-api-key $ETHERSCAN_API_KEY \
--verify \
src/RubyRingV1.sol:RubyRingV1
```

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
### Interact with deployed contract using [CAST](https://book.getfoundry.sh/cast/#overview-of-cast)

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Updated the `DEPLOYED_CONTRACT_ADDRESS` env variable with the contract address deployed previously

## Update fee destination addresses

```
cast send $DEPLOYED_CONTRACT_ADDRESS --private-key $PRIVATE_KEY \
"setFeeDestination(address)" <ADDRESS_FOR_FEE_DESTINATION> \
--rpc-url $RPC_URL
```

## Update protocol fee percent

```
cast send $DEPLOYED_CONTRACT_ADDRESS --private-key $PRIVATE_KEY \
--rpc-url $RPC_URL
"setProtocolFeePercent(uint256)" <FEE_PERCENT_IN_WEI> \
```

e.g.,

```
cast send $DEPLOYED_CONTRACT_ADDRESS --private-key $PRIVATE_KEY --rpc-url $RPC_URL "setProtocolFeePercent(uint256)" 50000000000000000 # 0.05%
```

## Update subject fee percent

```
cast send $DEPLOYED_CONTRACT_ADDRESS --private-key $PRIVATE_KEY \
"setSubjectFeePercent(uint256)" <FEE_PERCENT_IN_WEI> \
--rpc-url $RPC_URL
```

e.g.,

```
cast send $DEPLOYED_CONTRACT_ADDRESS --private-key $PRIVATE_KEY --rpc-url $RPC_URL "setSubjectFeePercent(uint256)" 50000000000000000 # 0.05%
```

## Contract calls

#### Example: getBuyPrice()

```
cast call $DEPLOYED_CONTRACT_ADDRESS "getBuyPrice(address, uint256)" \
<GEM_SUBJECT_ADDRESS> <AMOUNT_TO_BUY> \
--rpc-url $RPC_URL
```

e.g.,

```
cast call $DEPLOYED_CONTRACT_ADDRESS "getBuyPrice(address, uint256)" 0xFd7f2FD12c04De6959FBA1cF53bDfC1A608E3377 2 --rpc-url $RPC_URL
```

#### Example: gemsBalance()

```
cast call $DEPLOYED_CONTRACT_ADDRESS "gemsBalance(address, address)" \
<GEM_SUBJECT_ADDRESS> <USER_ADDRESS> \
--rpc-url $RPC_URL
```

e.g.,

```
cast call $DEPLOYED_CONTRACT_ADDRESS "gemsBalance(address, address)" 0x05789ff70a29041fbe618ed0d0674e2b3998df1f 0x05789ff70a29041fbe618ed0d0674e2b3998df1f --rpc-url $RPC_URL
```
# Backend Documentation

## Requirements
- MongoDB (https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-os-x/)
- Python 3
- Pip 3

## Installation
```
cd backend
source venv/bin/activate
source .env
pip install -r requirements.txt
```

## Cool to have
- MongoDB Compass GUI (Handy GUI for the mongodb database)

## Running the Backend
```
sh ./scripts/run.sh
```

## API Docs OpenAPI
After running the backend head to `http://127.0.0.1:8000/docs`

## Tests
```
python -m pytest test
```

0 comments on commit f6522b8

Please sign in to comment.