-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.js
More file actions
69 lines (61 loc) · 2.47 KB
/
setup.js
File metadata and controls
69 lines (61 loc) · 2.47 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
const fs = require("fs");
const path = require("path");
console.log("🚀 Token Auto Buy/Sell Setup");
console.log("============================\n");
// Create .env file if it doesn't exist
const envPath = path.join(__dirname, ".env");
const envExamplePath = path.join(__dirname, ".env.example");
if (!fs.existsSync(envPath)) {
if (fs.existsSync(envExamplePath)) {
fs.copyFileSync(envExamplePath, envPath);
console.log("✅ Created .env file from .env.example");
} else {
// Create basic .env file
const envContent = `# BSC Configuration
WALLET_PRIVATE_KEY=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
BSC_RPC_URL=https://bsc-dataseed.binance.org
BSC_CHAIN_ID=56
PANCAKESWAP_ROUTER=0x10ED43C718714eb63d5aA57B78B54704E256024E
# Solana Configuration
SOLANA_PRIVATE_KEY=[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]
SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
# Server Configuration
PORT=3000
NODE_ENV=development
`;
fs.writeFileSync(envPath, envContent);
console.log("✅ Created basic .env file");
}
} else {
console.log("ℹ️ .env file already exists");
}
// Check if node_modules exists
const nodeModulesPath = path.join(__dirname, "node_modules");
if (!fs.existsSync(nodeModulesPath)) {
console.log("📦 Installing dependencies...");
const { execSync } = require("child_process");
try {
execSync("npm install", { stdio: "inherit" });
console.log("✅ Dependencies installed successfully");
} catch (error) {
console.log("❌ Failed to install dependencies:", error.message);
console.log("Please run: npm install");
}
} else {
console.log("ℹ️ Dependencies already installed");
}
console.log("\n📋 Next Steps:");
console.log(
"1. Configure your .env file with real private keys (optional for demo mode)"
);
console.log("2. Start the server: npm run dev");
console.log("3. Test the API: node test-trade.js");
console.log("\n🔧 Configuration:");
console.log("- BSC: Set WALLET_PRIVATE_KEY for real BSC transactions");
console.log("- Solana: Set SOLANA_PRIVATE_KEY for real Solana transactions");
console.log("- Testnet: Update RPC URLs to testnet endpoints");
console.log("\n⚠️ Security:");
console.log("- Never commit private keys to version control");
console.log("- Use testnet for testing");
console.log("- Start with small amounts");
console.log("\n✨ Setup complete!");