-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
Β·324 lines (264 loc) Β· 7.98 KB
/
setup.sh
File metadata and controls
executable file
Β·324 lines (264 loc) Β· 7.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
#!/bin/bash
# π¦ Unicorn.eth PolyPrize Collection - Quick Setup Script
# This script sets up the complete project structure for the NFT claiming dapp
echo "π¦ Setting up Unicorn.eth PolyPrize Collection..."
# Check if Node.js is installed
if ! command -v node &> /dev/null; then
echo "β Node.js is not installed. Please install Node.js first."
exit 1
fi
# Create React app
echo "π¦ Creating React application..."
npx create-react-app unicorn-polyprize-minidapp
cd unicorn-polyprize-minidapp
# Install dependencies
echo "β¬οΈ Installing ThirdWeb dependencies..."
npm install @thirdweb-dev/react @thirdweb-dev/sdk @thirdweb-dev/chains
# Install Tailwind CSS (must be installed before init)
echo "π¨ Installing Tailwind CSS..."
npm install -D tailwindcss postcss autoprefixer
# Initialize Tailwind config (after installation)
echo "βοΈ Initializing Tailwind configuration..."
npx tailwindcss init -p
# Create directory structure
echo "π Creating project structure..."
mkdir -p src/components src/hooks src/utils src/styles contracts
# Create environment files
echo "βοΈ Creating environment configuration..."
cat > .env.example << 'EOF'
# ThirdWeb Configuration
REACT_APP_THIRDWEB_CLIENT_ID=your_client_id_here
# Contract Configuration
REACT_APP_CONTRACT_ADDRESS=0x1234567890123456789012345678901234567890
# Network Configuration
REACT_APP_CHAIN_ID=137
REACT_APP_NETWORK_NAME=polygon
# Optional: Analytics & Monitoring
REACT_APP_GA_TRACKING_ID=G-XXXXXXXXXX
EOF
cp .env.example .env.local
# Create Tailwind config
cat > tailwind.config.js << 'EOF'
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
"./public/index.html"
],
theme: {
extend: {
colors: {
purple: {
800: '#5B21B6',
900: '#4C1D95'
}
},
animation: {
'pulse-slow': 'pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite',
}
},
},
plugins: [],
}
EOF
# Create PostCSS config
cat > postcss.config.js << 'EOF'
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
EOF
# Update package.json scripts
echo "π Updating package.json..."
npm pkg set scripts.deploy="npm run build && echo 'Build complete! Upload build/ folder to your hosting provider'"
# Create constants file
cat > src/utils/constants.js << 'EOF'
export const CONTRACT_ADDRESS = process.env.REACT_APP_CONTRACT_ADDRESS || "";
export const CHAIN_ID = parseInt(process.env.REACT_APP_CHAIN_ID) || 137;
export const THIRDWEB_CLIENT_ID = process.env.REACT_APP_THIRDWEB_CLIENT_ID || "";
export const MESSAGES = {
ACCESS_DENIED: "Access denied - unauthorized wallet",
CLAIMING_IN_PROGRESS: "Claiming your soul-bound NFT...",
CLAIM_SUCCESS: "Successfully claimed! π",
CLAIM_FAILED: "Claiming failed. Please try again.",
DRAWING_ENDED: "Drawing has ended",
};
export const STATUS_TYPES = {
AUTHORIZED: 'Authorized',
UNAUTHORIZED: 'Unauthorized',
CLAIMED: 'Claimed',
NOT_CLAIMED: 'Not Claimed',
ACTIVE: 'Active',
ENDED: 'Ended',
PAUSED: 'Paused',
};
EOF
# Create useAutoConnect hook
cat > src/hooks/useAutoConnect.js << 'EOF'
import { useState, useEffect } from 'react';
import { useConnectionStatus, useAddress } from "@thirdweb-dev/react";
export const useAutoConnect = () => {
const connectionStatus = useConnectionStatus();
const address = useAddress();
const [isAutoConnected, setIsAutoConnected] = useState(false);
const [connectionType, setConnectionType] = useState('');
useEffect(() => {
if (connectionStatus === "connected" && address) {
const wasAutoConnected = localStorage.getItem('thirdweb:autoConnect') === 'true';
setIsAutoConnected(wasAutoConnected);
setConnectionType(wasAutoConnected ? 'Auto-Connected' : 'Manual Connection');
} else if (connectionStatus === "disconnected") {
setIsAutoConnected(false);
setConnectionType('');
}
}, [connectionStatus, address]);
return { isAutoConnected, connectionType };
};
EOF
# Create useCountdown hook
cat > src/hooks/useCountdown.js << 'EOF'
import { useState, useEffect } from 'react';
export const useCountdown = (targetTimestamp) => {
const [countdown, setCountdown] = useState("");
useEffect(() => {
if (!targetTimestamp) return;
const timer = setInterval(() => {
const now = Math.floor(Date.now() / 1000);
const drawingTimestamp = parseInt(targetTimestamp.toString());
const timeLeft = drawingTimestamp - now;
if (timeLeft <= 0) {
setCountdown("Drawing has ended");
clearInterval(timer);
return;
}
const days = Math.floor(timeLeft / 86400);
const hours = Math.floor((timeLeft % 86400) / 3600);
const minutes = Math.floor((timeLeft % 3600) / 60);
const seconds = timeLeft % 60;
setCountdown(`${days}d ${hours}h ${minutes}m ${seconds}s`);
}, 1000);
return () => clearInterval(timer);
}, [targetTimestamp]);
return countdown;
};
EOF
# Update src/index.css to include Tailwind
cat > src/index.css << 'EOF'
@tailwind base;
@tailwind components;
@tailwind utilities;
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
EOF
# Create gitignore
cat > .gitignore << 'EOF'
# Dependencies
node_modules/
.pnp
.pnp.js
# Testing
coverage/
# Production build
build/
# Environment variables
.env.local
.env.development.local
.env.test.local
.env.production.local
# Logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# IDE
.vscode/
.idea/
# OS
.DS_Store
Thumbs.db
# Contract artifacts
contracts/artifacts/
contracts/cache/
# Deployment
deploy.json
EOF
# Create README
cat > README.md << 'EOF'
# π¦ Unicorn.eth PolyPrize Collection
Authorized-access soul-bound NFT claiming dapp for the PolyPrize lottery system.
## β‘ Quick Start
1. **Configure Environment**
```bash
cp .env.example .env.local
# Edit .env.local with your actual values
```
2. **Get ThirdWeb Client ID**
- Visit https://thirdweb.com/dashboard
- Create new project and get Client ID
- Add to .env.local
3. **Deploy Contract**
```bash
# Use ThirdWeb deploy or your preferred method
npx thirdweb deploy
```
4. **Start Development**
```bash
npm start
```
## π Access Control
- Only wallets with `autoConnect` enabled can claim NFTs
- Manual wallet connections are blocked from claiming
- Perfect for authorized-user-only distributions
## π Deploy to Production
```bash
npm run build
# Upload build/ folder to Vercel, Netlify, or your hosting provider
```
## π Key Features
- β
Soul-bound NFTs (non-transferable)
- β
Auto-connect authorization only
- β
Time-limited claiming window
- β
Max supply protection (10,000 NFTs)
- β
Admin pause/unpause controls
- β
On-chain metadata generation
- β
Real-time countdown timer
Built with β€οΈ by @cryptowampum and Claude AI for unicorn.eth
EOF
echo ""
echo "β
Setup complete! Here's what to do next:"
echo ""
echo "1. π Get your ThirdWeb Client ID:"
echo " - Visit: https://thirdweb.com/dashboard"
echo " - Create project and copy Client ID"
echo " - Add to .env.local file"
echo ""
echo "2. π Deploy your contract:"
echo " - Upload your unicorn image to IPFS"
echo " - Use: npx thirdweb deploy"
echo " - Add contract address to .env.local"
echo ""
echo "3. π Start developing:"
echo " cd unicorn-polyprize-dapp"
echo " npm start"
echo ""
echo "4. π± Replace src/App.js with the provided React component"
echo ""
echo "π¦ Your Unicorn.eth PolyPrize dapp is ready to build!"
# Final reminder
echo ""
echo "β οΈ IMPORTANT: Remember to:"
echo " - Never commit .env.local to git"
echo " - Test on Mumbai testnet first"
echo " - Set up authorized wallets before launch"
echo " - Configure your drawing date carefully"