Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["next/core-web-vitals", "next/typescript"]
}
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# env files
.env*
!.env.example

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# Serwist
public/sw*
public/swe-worker*
80 changes: 79 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,79 @@
# athena-hacker-house
# BlindDiceSwap

**BlindDiceSwap** is a gamified Web3 token swapping experience where chance meets DeFi. Users roll a dice to determine which token they receive in exchange for **WMON**, making every swap exciting and unpredictable.

---

## Why BlindDiceSwap is Cool

- **Gamified Swaps:** Dice rolls make swapping tokens interactive and exciting.
- **Randomized Rewards:** Each dice roll randomly determines the token and swap amount.
- **Instant Swaps:** 0x API ensures fast, reliable, and secure swaps.

---

## Extra Feature – Mandatory Swap Confirmation

If a user cancels a transaction, **MetaMask (or the connected wallet) will pop up again**. Once the **Roll Dice** button is clicked, confirming the swap transaction becomes **compulsory**, ensuring users cannot bypass the intended swap.

---

## Dice Roll Mechanism

- Users click the **Roll Dice** button.
- Dice results are randomized between **1–6**.
- Each number maps to a token:
- **1 → USDT**
- **2 → USDC**
- **3 → DAK**
- **4 → CHOG**
- **5 → YAKI**
- **6 → KB**

---

## Token Swaps via 0x API

- Dice outcome triggers a **WMON → selected token swap**.
- Swap amounts are randomized between **0.01–0.5 WMON**.
- 0x API ensures:
- Optimal liquidity
- Minimal slippage
- Secure execution
- Users see a **live update**: dice result, token received, and swap amount.

---

## Tech Stack

- **Frontend:** React.js, Next.js, Tailwind CSS
- **Wallet & Auth:** Privy Embedded Wallet / MetaMask
- **Token Swap:** 0x API
- **Blockchain:** Monad-compatible EVM network
- **Smart Contracts:** Solidity

---

## How It Works

1. User logs in with Privy or MetaMask.
2. User clicks **Roll Dice**.
3. Dice result determines which token is swapped.
4. Swap is executed via **0x API**.
5. If the user cancels, wallet prompt appears again until confirmed.
6. Swap results are displayed instantly: token received and WMON spent.

---

## Future Enhancements

- Chainlink VRF for verifiable randomness
- Multi-token rewards beyond WMON
- Seasonal challenges or tournaments
- Push notifications for swaps and rewards

---

## Screenshots / Demo

*(Add screenshots or GIFs of dice roll, swap result, and wallet popup here)*
20 changes: 20 additions & 0 deletions app/api/allowance-holder/price/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { type NextRequest } from "next/server";

export async function GET(request: NextRequest) {
const searchParams = request.nextUrl.searchParams;

const res = await fetch(
`https://api.0x.org/swap/allowance-holder/price?${searchParams}`,
{
headers: {
"0x-api-key": process.env.ZEROX_API_KEY as string,
"0x-version": "v2",
},
}
);
const data = await res.json();

return Response.json(data);
}


20 changes: 20 additions & 0 deletions app/api/allowance-holder/quote/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { type NextRequest } from "next/server";

export async function GET(request: NextRequest) {
const searchParams = request.nextUrl.searchParams;

const res = await fetch(
`https://api.0x.org/swap/allowance-holder/quote?${searchParams}`,
{
headers: {
"0x-api-key": process.env.ZEROX_API_KEY as string,
"0x-version": "v2",
},
}
);
const data = await res.json();

return Response.json(data);
}


29 changes: 29 additions & 0 deletions app/api/price/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { type NextRequest } from "next/server";

export async function GET(request: NextRequest) {
const searchParams = request.nextUrl.searchParams;

try {
const res = await fetch(
`https://api.0x.org/swap/permit2/price?${searchParams}`,
{
headers: {
"0x-api-key": process.env.ZEROX_API_KEY as string,
"0x-version": "v2",
},
}
);
const data = await res.json();

console.log(
"price api",
`https://api.0x.org/swap/permit2/price?${searchParams}`
);

console.log("price data", data);

return Response.json(data);
} catch (error) {
console.log(error);
}
}
25 changes: 25 additions & 0 deletions app/api/quote-classic/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { type NextRequest } from "next/server";

export async function GET(request: NextRequest) {
const searchParams = request.nextUrl.searchParams;

const res = await fetch(
`https://api.0x.org/swap/quote?${searchParams}`,
{
headers: {
"0x-api-key": process.env.ZEROX_API_KEY as string,
"0x-version": "v2",
},
}
);
const data = await res.json();

console.log(
"classic quote api",
`https://api.0x.org/swap/quote?${searchParams}`
);

return Response.json(data);
}


23 changes: 23 additions & 0 deletions app/api/quote/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { type NextRequest } from "next/server";

export async function GET(request: NextRequest) {
const searchParams = request.nextUrl.searchParams;

const res = await fetch(
`https://api.0x.org/swap/permit2/quote?${searchParams}`,
{
headers: {
"0x-api-key": process.env.ZEROX_API_KEY as string,
"0x-version": "v2",
},
}
);
const data = await res.json();

console.log(
"quote api",
`https://api.0x.org/swap/permit2/quote?${searchParams}`
);

return Response.json(data);
}
Loading