starkzap-starter 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +23 -0
- package/README.md +164 -0
- package/cli-package.json +31 -0
- package/next.config.mjs +8 -0
- package/package.json +33 -0
- package/postcss.config.js +6 -0
- package/scripts/create-starkzap-app.mjs +1749 -0
- package/src/app/globals.css +46 -0
- package/src/app/layout.tsx +21 -0
- package/src/app/page.tsx +159 -0
- package/src/components/payment/PaymentForm.tsx +158 -0
- package/src/components/wallet/TokenBalanceCard.tsx +79 -0
- package/src/components/wallet/WalletButton.tsx +59 -0
- package/src/hooks/useGaslessTransfer.ts +88 -0
- package/src/hooks/useTokenBalance.ts +66 -0
- package/src/hooks/useWallet.ts +88 -0
- package/src/lib/starkzap.ts +22 -0
- package/src/lib/utils.ts +54 -0
- package/tailwind.config.js +43 -0
- package/tsconfig.json +22 -0
package/.env.example
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# ─────────────────────────────────────────────────────────────
|
|
2
|
+
# Starkzap Starter — Environment Variables
|
|
3
|
+
# Copy this file to .env.local and fill in your values.
|
|
4
|
+
# NEVER commit .env.local to version control.
|
|
5
|
+
# ─────────────────────────────────────────────────────────────
|
|
6
|
+
|
|
7
|
+
# Network: "sepolia" for testnet, "mainnet" for production
|
|
8
|
+
NEXT_PUBLIC_STARKNET_NETWORK=sepolia
|
|
9
|
+
|
|
10
|
+
# Your Starknet RPC endpoint (get a free one from Blast, Infura, or Alchemy)
|
|
11
|
+
NEXT_PUBLIC_STARKNET_RPC_URL=https://starknet-sepolia.public.blastapi.io
|
|
12
|
+
|
|
13
|
+
# ── Privy (Social/Email Login) ────────────────────────────────
|
|
14
|
+
# Get your App ID from https://privy.io — required for social login wallet
|
|
15
|
+
NEXT_PUBLIC_PRIVY_APP_ID=
|
|
16
|
+
|
|
17
|
+
# ── AVNU Paymaster (Gasless Transactions) ────────────────────
|
|
18
|
+
# Optional: leave blank to skip gas sponsorship (users pay their own gas)
|
|
19
|
+
NEXT_PUBLIC_AVNU_API_KEY=
|
|
20
|
+
|
|
21
|
+
# ── App Config ────────────────────────────────────────────────
|
|
22
|
+
NEXT_PUBLIC_APP_NAME=Starkzap Starter
|
|
23
|
+
NEXT_PUBLIC_APP_URL=http://localhost:3000
|
package/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# create-starkzap-app
|
|
2
|
+
|
|
3
|
+
A CLI scaffold for production-ready Starknet applications. Choose your framework, pick your wallet strategy, and get a fully wired app in seconds — gasless transactions, token balances, and wallet connect included.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx create-starkzap-app
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Frameworks
|
|
12
|
+
|
|
13
|
+
Pick your stack when scaffolding. All three share the same Starkzap SDK core.
|
|
14
|
+
|
|
15
|
+
| | Next.js 14 | Vite + React | Expo (Mobile) |
|
|
16
|
+
|---|---|---|---|
|
|
17
|
+
| **Best for** | Production web apps, SEO, SSR | SPAs, dashboards, lightweight | iOS & Android |
|
|
18
|
+
| **Router** | App Router | React Router / file-based | Expo Router |
|
|
19
|
+
| **Wallet** | Argent X, Braavos, Privy | Argent X, Braavos, Privy | Privy (email/social) |
|
|
20
|
+
| **Bundle** | Next.js optimized | Vite | Metro |
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## What's Included
|
|
25
|
+
|
|
26
|
+
Every scaffold comes with the following out of the box:
|
|
27
|
+
|
|
28
|
+
| Feature | Details |
|
|
29
|
+
|---|---|
|
|
30
|
+
| 🔑 Wallet Connect | Argent X + Braavos via injected provider. Privy social login supported. |
|
|
31
|
+
| ⛽ Gasless Transactions | AVNU paymaster covers gas — users pay nothing. |
|
|
32
|
+
| 💰 Token Balances | Live STRK, ETH, USDC balance cards with refresh. |
|
|
33
|
+
| 💸 Payment UI | Send form with pending / success / error states. |
|
|
34
|
+
| 🔗 Explorer Links | Auto-links transactions and addresses to Starkscan. |
|
|
35
|
+
| 🎨 Design System | Dark theme, DM Sans + IBM Plex Mono, Tailwind CSS. |
|
|
36
|
+
|
|
37
|
+
**Stack:** Next.js 14 · Vite 5 · Expo 51 · TypeScript · Starkzap SDK · Tailwind CSS · starknet.js
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Quickstart
|
|
42
|
+
|
|
43
|
+
### 1. Scaffold
|
|
44
|
+
|
|
45
|
+
Run the CLI and follow the prompts — choose your project name, framework, and wallet strategy:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx create-starkzap-app
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 2. Configure
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cp .env.example .env.local
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Open `.env.local` and fill in:
|
|
58
|
+
|
|
59
|
+
```env
|
|
60
|
+
# "sepolia" for testnet, "mainnet" for production
|
|
61
|
+
NEXT_PUBLIC_STARKNET_NETWORK=sepolia
|
|
62
|
+
|
|
63
|
+
# Free RPC endpoints:
|
|
64
|
+
# Blast: https://starknet-sepolia.public.blastapi.io
|
|
65
|
+
# Infura: https://starknet-sepolia.infura.io/v3/YOUR_KEY
|
|
66
|
+
NEXT_PUBLIC_STARKNET_RPC_URL=https://starknet-sepolia.public.blastapi.io
|
|
67
|
+
|
|
68
|
+
# Optional — Privy app ID for social/email login (https://privy.io)
|
|
69
|
+
NEXT_PUBLIC_PRIVY_APP_ID=
|
|
70
|
+
|
|
71
|
+
# Optional — AVNU API key for gasless transactions (leave blank to skip)
|
|
72
|
+
NEXT_PUBLIC_AVNU_API_KEY=
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 3. Run
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npm run dev
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Open [http://localhost:3000](http://localhost:3000) and connect your wallet.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Extending the Kit
|
|
86
|
+
|
|
87
|
+
### Token Swaps via AVNU
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { StarkZap, AvnuSwapProvider, getPresets, Amount } from "starkzap";
|
|
91
|
+
|
|
92
|
+
const sdk = new StarkZap({ network: "mainnet" });
|
|
93
|
+
const wallet = await sdk.connectWallet({
|
|
94
|
+
account: { signer },
|
|
95
|
+
swapProviders: [new AvnuSwapProvider()],
|
|
96
|
+
defaultSwapProviderId: "avnu",
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const { STRK, USDC } = getPresets(wallet.getChainId());
|
|
100
|
+
const tx = await wallet.swap({
|
|
101
|
+
tokenIn: STRK,
|
|
102
|
+
tokenOut: USDC,
|
|
103
|
+
amountIn: Amount.parse("10", STRK),
|
|
104
|
+
slippageBps: 50n,
|
|
105
|
+
});
|
|
106
|
+
await tx.wait();
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### STRK Staking
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
const stakingPools = await wallet.staking().getPools();
|
|
113
|
+
const tx = await wallet.staking().stake({
|
|
114
|
+
pool: stakingPools[0],
|
|
115
|
+
amount: Amount.parse("100", STRK),
|
|
116
|
+
});
|
|
117
|
+
await tx.wait();
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Batch Multiple Transactions
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
const tx = await wallet
|
|
124
|
+
.tx()
|
|
125
|
+
.transfer({ to: addr1, token: STRK, amount: Amount.parse("5", STRK) })
|
|
126
|
+
.transfer({ to: addr2, token: USDC, amount: Amount.parse("10", USDC) })
|
|
127
|
+
.execute({ feeMode: "sponsored" });
|
|
128
|
+
await tx.wait();
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Deployment
|
|
134
|
+
|
|
135
|
+
### Vercel (Recommended)
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
npm install -g vercel
|
|
139
|
+
vercel
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Set your environment variables in the Vercel dashboard. Switch `NEXT_PUBLIC_STARKNET_NETWORK` to `mainnet` for production.
|
|
143
|
+
|
|
144
|
+
### Manual Build
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
npm run build
|
|
148
|
+
npm start
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Resources
|
|
154
|
+
|
|
155
|
+
- [Starkzap Documentation](https://docs.starknet.io/build/starkzap/overview)
|
|
156
|
+
- [Starkzap GitHub](https://github.com/keep-starknet-strange/starkzap)
|
|
157
|
+
- [AVNU Paymaster](https://www.avnu.fi)
|
|
158
|
+
- [Privy Docs](https://docs.privy.io)
|
|
159
|
+
- [Starkscan — Sepolia](https://sepolia.starkscan.co)
|
|
160
|
+
- [Starkscan — Mainnet](https://starkscan.co)
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
MIT License · Built on [Starknet](https://starknet.io)
|
package/cli-package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-starkzap-app",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Interactive CLI to scaffold a Starkzap + Starknet app — Next.js or Vite, Privy or Cartridge",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-starkzap-app": "./scripts/create-starkzap-app.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"scripts/"
|
|
11
|
+
],
|
|
12
|
+
"keywords": [
|
|
13
|
+
"starknet",
|
|
14
|
+
"starkzap",
|
|
15
|
+
"create-app",
|
|
16
|
+
"web3",
|
|
17
|
+
"scaffold",
|
|
18
|
+
"cli",
|
|
19
|
+
"nextjs",
|
|
20
|
+
"privy",
|
|
21
|
+
"cartridge"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/fati-Onchain/starkzap-starter"
|
|
29
|
+
},
|
|
30
|
+
"license": "MIT"
|
|
31
|
+
}
|
package/next.config.mjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "starkzap-starter",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Next.js 14 App Router starter kit for building on Starknet with the Starkzap SDK",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "next dev",
|
|
8
|
+
"build": "next build",
|
|
9
|
+
"start": "next start",
|
|
10
|
+
"lint": "next lint",
|
|
11
|
+
"type-check": "tsc --noEmit"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"next": "^14.2.0",
|
|
15
|
+
"react": "^18.3.0",
|
|
16
|
+
"react-dom": "^18.3.0",
|
|
17
|
+
"starkzap": "latest",
|
|
18
|
+
"starknet": "^6.11.0",
|
|
19
|
+
"clsx": "^2.1.1",
|
|
20
|
+
"tailwind-merge": "^2.3.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^20",
|
|
24
|
+
"@types/react": "^18",
|
|
25
|
+
"@types/react-dom": "^18",
|
|
26
|
+
"typescript": "^5",
|
|
27
|
+
"tailwindcss": "^3.4.0",
|
|
28
|
+
"autoprefixer": "^10.4.0",
|
|
29
|
+
"postcss": "^8.4.0",
|
|
30
|
+
"eslint": "^8",
|
|
31
|
+
"eslint-config-next": "14.2.0"
|
|
32
|
+
}
|
|
33
|
+
}
|