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
Binary file added contest_submissions/.DS_Store
Binary file not shown.
68 changes: 68 additions & 0 deletions contest_submissions/xmerch/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
## Optimzely Configuration
# Obtain your Optimzely API Key from your Optimzely account
OPTIMIZELY_API_KEY=your_optimzely_api_key_here
OPTIMIZELY_SDK_KEY=your_optimzely_sdk_key_here
OPTIMIZELY_PROJECT_ID=your_optimzely_project_id_here

# Webhook Secret - Generate a secret with: node -e "console.log(crypto.randomBytes(32).toString('base64url'))"
OPTIMIZELY_WEBHOOK_SECRET=your_webhook_secret_here



#vercel.com
# Feature Flags Secret Key
FLAGS_SECRET=your_flags_secret_here
# Edge Configuration URL (Replace with your own Vercel Edge Config URL)
EDGE_CONFIG=your_vercel_edge_config_url_here
# Team ID (Use the team ID from your project settings)
TEAM_ID=your_team_id_here
# API Token (Use the API token generated in your account settings)
API_TOKEN=your_api_token_here

## Xaman Wallet XRPL you will need to create two xapps
# XUMM API keys for XRPL - Obtain from Xaman Developer Portal
NEXT_PUBLIC_XUMM_XRPL_API_KEY=your_xrpl_xumm_api_key_here
XUMM_XRPL_API_SECRET=your_xrpl_xumm_api_secret_here

## Xaman Wallet Xahau
# XUMM API keys for Xahau - Obtain from Xaman Developer Portal
NEXT_PUBLIC_XUMM_XAHAU_API_KEY=your_xahau_xumm_api_key_here
XUMM_XAHAU_API_SECRET=your_xahau_xumm_api_secret_here

# Default Network Selection
NEXT_PUBLIC_DEFAULT_NETWORK=xahau

# Store Destination Wallet Address (Replace with your store's XUMM wallet address)
XUMM_DESTINATION_ADDRESS=your_destination_wallet_address_here

## XUMM API Base URL (Default: XUMM's API endpoint)
XUMM_API_BASE_URL=https://xumm.app/api/v1

## Public XRP Ledger Node (XRPL Transaction Validation)
XRP_LEDGER_BASE_URL=wss://xrplcluster.com

## XRP Price Oracles
THREE_XRP_API=https://threexrp.dev/api

## Dhali API URL (Replace with your own API endpoint if using Dhali)
DHALI_API_URL=https://run.api.dhali.io/your_dhali_api_id_here/

# Dhali Payment Claim Details (Replace with your payment claim details)
DHALI_PAYMENT_CLAIM={"account":"your_account_here","destination_account":"your_destination_account_here","authorized_to_claim":"your_claim_amount_here","signature":"your_signature_here","channel_id":"your_channel_id_here"}

## Xahau Price Quote (CoinMarketCap API)
# Obtain API Key from CoinMarketCap Developer Portal
COINMARKETCAP_API_KEY=your_coinmarketcap_api_key_here

## Supabase Configuration
# Replace with your Supabase project details
NEXT_PUBLIC_SUPABASE_URL=https://your_supabase_project_url_here
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key_here

# Base URLs (Adjust based on your local or production environment)
NEXT_PUBLIC_BASE_URL=http://localhost:3000
NEXT_PUBLIC_API_URL=http://localhost:3000
NEXT_PUBLIC_WEBHOOK_URL=

# Node.js Warnings
#NODE_NO_WARNINGS=1 uncomment for testing
3 changes: 3 additions & 0 deletions contest_submissions/xmerch/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
37 changes: 37 additions & 0 deletions contest_submissions/xmerch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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*

# local env files
#.env*.local
#.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
1 change: 1 addition & 0 deletions contest_submissions/xmerch/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
21.0.0
169 changes: 169 additions & 0 deletions contest_submissions/xmerch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# XMerch

**XMerch** is a proof-of-concept (PoC) store demonstrating how to integrate **Next.js**, **XUMM**, and **XRPL/Xahau** payment flows to sell real-world merchandise without the hefty fees of traditional payment gateways. Our goal is to enable merchants—especially those with limited budgets or non-technical backgrounds—to easily accept cryptocurrency payments on the **XRPL** and **Xahau** networks.

> **Live URL (Pre-Production / Soft Launch):**
> [https://merch-25.vercel.app/](https://merch-25.vercel.app/)
> *(Currently only accepting real $XAH on Xahau mainnet for contest testing.)*

---

## Table of Contents

1. [Project Overview](#project-overview)
2. [Key Features](#key-features)
3. [Current Soft-Launch Logic](#current-soft-launch-logic)
4. [Database & Orders](#database--orders)
5. [Environment Variables](#environment-variables)
6. [Getting Started](#getting-started)
7. [Hooks & Smart Contracts](#hooks--smart-contracts)
8. [Roadmap / Upcoming Features](#roadmap--upcoming-features)
9. [Timeline](#timeline)
10. [Contribution & License](#contribution--license)
11. [Contact / Feedback](#contact--feedback)

---

## 1. Project Overview

### What is XMerch?
XMerch is a template/stack for showcasing real-world commerce on the XRPL and Xahau networks. It allows merchants to accept crypto payments with minimal transaction fees compared to traditional gateways (Stripe, Square, etc.).

### Why XMerch?
- Many small businesses are forced to pay high fees or handle complicated integrations when trying to accept crypto payments.
- We aim to provide user-friendly repos and guides for quickly deploying a Web3-compatible store.

### Contest Submission
This repository (or branch) is prepared for the [Xahau Dev Contest](https://github.com/XRPL-Labs/Xahau-Dev-Contest). It demonstrates a working payment flow using **$XAH** on the mainnet.

---

## 2. Key Features

### Live (Soft-Launch) Storefront
- Deployed on Vercel at [merch-25.vercel.app](https://merch-25.vercel.app/).
- Currently forces **$XAH** payments on mainnet (though logic for XRPL is present).

### Transaction Workflow
- Each product is priced at **0.01 $XAH** + shipping/handling of **0.03 $XAH**.
- Payments handled via [XUMM](https://xumm.app/) integration.

### Reward Mechanism
- **50%** of each sale goes to a **vault** via our `rewardHook`.
- Future random giveaways from the vault to testers.

### Data Storage & Orders
- Shipping address, email, and order info are stored in a Supabase database.
- `/orders` page shows recent purchases, tied to each wallet address.

### Preconfigured Stack
- Built on **Next.js** (with EvernodeXRPL Hosting in the pipe).
- Currently includes placeholder experimentation code from [Optimizely Feature Experimentation](https://www.optimizely.com/products/feature-experimentation/) and Vercel Edge Config.

---

## 3. Current Soft-Launch Logic

- **Mainnet Only**: For the **Xahau Dev Contest**, the store is forced to accept $XAH (Xahau mainnet).
- **Dev Testing**: We invite devs to buy mock products (no physical delivery during soft-launch).
- **Shipping Form**: Shipping address must be entered (dummy address is acceptable), but a valid email is requested for potential order tracking.
- **Vault Split**: Once a payment is confirmed, 50% is automatically sent to the vault. The other 50% goes to the merchant’s address.

---

## 4. Database & Orders

### Supabase Integration
- We store user wallet addresses, shipping address, and email.
- This allows us to track orders on the `/orders` page.

### XRPL vs. Xahau
- Our code can handle both XRPL and Xahau transactions. However, for the contest, XMerch uses Xahau exclusively.
- After the contest, XRPL network switching can be re-enabled to support multiple networks in production.

---

## 5. Environment Variables
_(See `env.example` for details on required variables)_

---

## 6. Getting Started

### Clone & Install
```bash
git clone https://github.com/mworks-proj/xmerch
cd xmerch
pnpm install
```

### Environment Setup
- Copy `.env.example` to `.env` and fill in real values (if you plan to run local tests).
- Ensure you have the correct wallet details if you want to test mainnet transactions.

### Run Development Server
```bash
pnpm run dev
```
- Visit [http://localhost:3000](http://localhost:3000) to view the store.


### Testing webhook requires NGROK (https://ngrok.com/ )


### Test a Purchase
- Pick an item (product price .01 + 0.01 shipping + 10% handling = total 0.03 ).
- Connect XUMM (using your Xahau wallet).
- Enter shipping details (dummy address is fine).
- Confirm the payment on your XUMM app.
- Check Order via 🔎 explorer link

---

## 7. Hooks & Smart Contracts

### `rewardHook`
- Automatically splits **50%** of the sale price into a **vault**.
- The logic can track or annotate the transaction with memos/hashes.

### `giveawayHook` (Upcoming)
- Will randomly select a wallet from the vault’s transaction list to receive a giveaway.
- Enhanced by logging transaction memos or hashes to identify participants.

### `subscriptionHook` (Planned)
- Future recurring payment model for SaaS or subscription-based purchases on Xahau.

---

## 8. Roadmap / Upcoming Features

1. **BlindBox / Recurring Subscriptions**
2. **Automated Fulfillment**
3. **Multi-Network Support**
4. **Stronger Validation**
5. **Analytics & Insights**

---

## 9. Timeline

- **Submission Date**: January 31 (Xahau Dev Contest)
- **Live Product Drop ETA**: February 5

---

## 10. Contribution & License

- **Contributions**: Open an Issue for feedback.
- **License**: MIT License

---

## 11. Contact / Feedback

- **Team**: XMerch by Meister w/ MWORKS
- **Email**: [email protected]
- **Issues**: [GitHub Issues](https://github.com/your-org/xmerch-contest/issues)

> We welcome feedback from contest judges and community devs!

14 changes: 14 additions & 0 deletions contest_submissions/xmerch/app/.well-known/vercel/flags/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ApiData, verifyAccess } from "@vercel/flags";
import { unstable_getProviderData as getProviderData } from "@vercel/flags/next";
import { NextResponse, type NextRequest } from "next/server";
import * as flags from "../../../../lib/flags";

export const runtime = "edge";
export const dynamic = "force-dynamic";

export async function GET(request: NextRequest) {
const access = await verifyAccess(request.headers.get("Authorization"));
if (!access) return NextResponse.json(null, { status: 401 });

return NextResponse.json<ApiData>(getProviderData(flags));
}
Loading