-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.js
More file actions
111 lines (93 loc) · 3.24 KB
/
Copy pathsetup.js
File metadata and controls
111 lines (93 loc) · 3.24 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
'use strict';
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
const RESET = '\x1b[0m';
const GREEN = '\x1b[32m';
const YELLOW = '\x1b[33m';
const CYAN = '\x1b[36m';
const BOLD = '\x1b[1m';
function log(msg) { console.log(`${GREEN}[setup]${RESET} ${msg}`); }
function warn(msg) { console.log(`${YELLOW}[warn]${RESET} ${msg}`); }
function header(msg) { console.log(`\n${BOLD}${CYAN}${msg}${RESET}`); }
header('========================================');
header(' NFT Mint Bot - First Time Setup');
header('========================================');
// Step 1: Check Node.js version
header('1. Checking Node.js version...');
const nodeVersion = process.versions.node;
const major = parseInt(nodeVersion.split('.')[0]);
if (major < 18) {
warn(`Node.js ${nodeVersion} detected. Minimum required: 18.x`);
warn('Please upgrade: https://nodejs.org/');
process.exit(1);
}
log(`Node.js v${nodeVersion} - OK`);
// Step 2: Install dependencies
header('2. Installing dependencies...');
try {
execSync('npm install', { stdio: 'inherit', cwd: __dirname });
log('Dependencies installed');
} catch (err) {
warn('npm install failed. Try running manually: npm install');
process.exit(1);
}
// Step 3: Create .env from example
header('3. Setting up environment files...');
const envPath = path.join(__dirname, '.env');
const envExamplePath = path.join(__dirname, '.env.example');
const collectionEnvPath = path.join(__dirname, '.collection.env');
const collectionExamplePath = path.join(__dirname, '.collection.env.example');
if (!fs.existsSync(envPath)) {
if (fs.existsSync(envExamplePath)) {
fs.copyFileSync(envExamplePath, envPath);
log('.env created from .env.example');
} else {
warn('.env.example not found');
}
} else {
log('.env already exists - skipping');
}
if (!fs.existsSync(collectionEnvPath)) {
if (fs.existsSync(collectionExamplePath)) {
fs.copyFileSync(collectionExamplePath, collectionEnvPath);
log('.collection.env created from .collection.env.example');
} else {
warn('.collection.env.example not found');
}
} else {
log('.collection.env already exists - skipping');
}
// Step 4: Create logs directory
header('4. Creating logs directory...');
const logsDir = path.join(__dirname, 'logs');
if (!fs.existsSync(logsDir)) {
fs.mkdirSync(logsDir, { recursive: true });
log('logs/ directory created');
} else {
log('logs/ directory already exists');
}
// Step 5: Print next steps
header('========================================');
header(' Setup Complete!');
header('========================================');
console.log(`
${BOLD}Next Steps:${RESET}
1. Edit ${CYAN}.env${RESET} with your:
- RPC_URL (Alchemy/Infura/etc)
- PRIVATE_KEYS (comma-separated)
2. Edit ${CYAN}.collection.env${RESET} with target collection:
- CONTRACT_ADDRESS
- MINT_FUNCTION
- MINT_PRICE
- PLATFORM (or leave 'auto')
3. Run the bot:
${GREEN}node index.js${RESET}
4. For dry run (no real tx):
Set ${CYAN}DRY_RUN=true${RESET} in .env
${BOLD}Tips:${RESET}
- Use DRY_RUN=true to test without spending gas
- Use SIMULATE=true (default) to simulate before sending
- Check logs/ folder for detailed per-wallet logs
- Set LOG_LEVEL=debug for verbose output
`);