├── README.md ├── mawari-setup └── mawari-setup.sh /README.md: -------------------------------------------------------------------------------- 1 | 2 | # 🚀 Mawari Network Guardian Node Setup 3 | 4 |
5 | Mawari Network 6 | Status 7 | License 8 |
9 | 10 |
11 |

Automated Guardian Node Setup & Management Script

12 |

Complete solution for Mawari Network Guardian Node deployment with wallet management, faucet claiming, and delegation automation

13 |
14 | 15 | --- 16 | 17 | ## ✨ Key Features 18 | 19 | - **🔧 One-Click Installation**: Automated dependency installation (Docker, Python, etc.) 20 | - **🌐 Node Management**: Easy Guardian Node setup, monitoring, and status checking 21 | - **💳 Wallet Operations**: Wallet creation, burner address management, and private key access 22 | - **🚰 Faucet Automation**: Automated faucet claiming and token transfer to burner wallets 23 | - **🔗 Delegation Support**: Streamlined node delegation process with step-by-step guidance 24 | - **🛡️ Security First**: Secure private key handling with clipboard integration 25 | - **📊 Multi-Wallet Support**: Generate and manage multiple burner wallets simultaneously 26 | - **🔄 Screen Integration**: Run nodes in detached screen sessions for persistent operation 27 | 28 | --- 29 | 30 | ## 📋 Prerequisites 31 | 32 | - Linux-based operating system (Ubuntu 20.04+ recommended) 33 | - Basic command-line knowledge 34 | - Mawari Network wallet for claiming and delegation 35 | - Internet connection for package downloads 36 | 37 | --- 38 | 39 | ## 🚀 Quick Start 40 | 41 | ### 1. Clone the Repository 42 | ```bash 43 | git clone https://github.com/xPOURY4/mawari-node-setup.git 44 | cd mawari-node-setup 45 | ``` 46 | 47 | ### 2. Make Script Executable 48 | ```bash 49 | chmod +x mawari-setup.sh 50 | ``` 51 | 52 | ### 3. Run in Screen Session (Recommended) 53 | ```bash 54 | screen -S mawari 55 | ./mawari-setup.sh 56 | ``` 57 | 58 | ### 4. Detach from Screen 59 | After starting the script, detach from the screen session: 60 | ``` 61 | Ctrl + A, then D 62 | ``` 63 | 64 | ### 5. Reattach to Screen (When Needed) 65 | ```bash 66 | screen -r mawari 67 | ``` 68 | 69 | --- 70 | 71 | ## 📖 Detailed Usage Guide 72 | 73 | ### Running the Script 74 | 75 | The script provides an interactive menu system. You can run it either in a screen session (recommended for persistent operation) or directly in your terminal. 76 | 77 | #### Option A: Screen Session (Recommended) 78 | ```bash 79 | # Create new screen session 80 | screen -S mawari 81 | 82 | # Run the script 83 | ./mawari-setup.sh 84 | 85 | # Detach from screen (script continues running) 86 | Ctrl + A, then D 87 | 88 | # Reattach later 89 | screen -r mawari 90 | ``` 91 | 92 | #### Option B: Direct Terminal 93 | ```bash 94 | ./mawari-setup.sh 95 | ``` 96 | 97 | ### Main Menu Options 98 | 99 | | Option | Description | 100 | |--------|-------------| 101 | | **1** | Install Dependencies - Docker, Python, and required packages | 102 | | **2** | Create New Wallet - Guidance for wallet creation and NFT minting | 103 | | **3** | Claim Faucet & Mint 3X NFT - Instructions for faucet claiming | 104 | | **4** | Setup Guardian Node - Deploy and start Guardian Node container | 105 | | **5** | Check Burner Address - View burner address and private key | 106 | | **6** | Node Status - Check running node status and logs | 107 | | **7** | Delegate Node - Step-by-step delegation instructions | 108 | | **8** | Claim Faucet & Send to Burner - Automated claiming and transfer | 109 | | **9** | Exit - Safely exit the script | 110 | 111 | --- 112 | 113 | ## 🔐 Security Features 114 | 115 | ### Private Key Management 116 | - **Secure Display**: Private keys are displayed with clear warnings 117 | - **Clipboard Integration**: Automatic copying to clipboard (when `xclip` is installed) 118 | - **File Storage**: Secure storage in `~/mawari/` with restricted permissions 119 | - **Warning Messages**: Clear security warnings before displaying sensitive data 120 | 121 | ### Screen Session Benefits 122 | - **Persistent Operation**: Nodes continue running even after terminal closure 123 | - **Isolated Environment**: Separates node operation from management tasks 124 | - **Reattachable**: Easily reconnect to monitor or manage nodes 125 | - **Background Execution**: Nodes run without occupying your terminal 126 | 127 | --- 128 | 129 | ## 🛠️ Advanced Operations 130 | 131 | ### Checking Burner Address (Option 5) 132 | ```bash 133 | # Access burner wallet information 134 | - Displays burner address and private key 135 | - Copies both to clipboard automatically 136 | - Saves to files: 137 | - ~/mawari/burner_address.txt 138 | - ~/mawari/burner_private_key.txt 139 | - Shows security warnings 140 | ``` 141 | 142 | ### Node Status Monitoring (Option 6) 143 | ```bash 144 | # Check all running nodes 145 | - Lists active Docker containers 146 | - Shows resource usage 147 | - Provides quick access to logs 148 | ``` 149 | 150 | ### Automated Faucet Claiming (Option 8) 151 | ```bash 152 | # Automated claiming process 153 | - Creates claim bot if needed 154 | - Guides through credential setup 155 | - Automates faucet claiming and token transfer 156 | - Provides transaction receipts 157 | ``` 158 | 159 | --- 160 | 161 | ## 📁 Directory Structure 162 | 163 | ``` 164 | ~/mawari/ 165 | ├── flohive-cache.json # Node configuration 166 | ├── burner_address.txt # Saved burner addresses 167 | ├── burner_private_key.txt # Saved private keys 168 | ├── generated_wallets.log # Wallet generation log 169 | ├── setup.log # Installation logs 170 | ├── bot/ # Claim bot directory 171 | │ ├── mawari_claim_bot.py # Claim bot script 172 | │ └── creds.txt # Wallet credentials 173 | └── wallet_*/ # Individual wallet directories 174 | └── flohive-cache.json # Wallet-specific config 175 | ``` 176 | 177 | --- 178 | 179 | ## 🐳 Docker Integration 180 | 181 | The script uses Docker containers for reliable node deployment: 182 | 183 | ```bash 184 | docker run -d \ 185 | --name mawari-node \ 186 | --pull always \ 187 | -v ~/mawari:/app/cache \ 188 | -e OWNERS_ALLOWLIST=YOUR_WALLET_ADDRESS \ 189 | us-east4-docker.pkg.dev/mawarinetwork-dev/mwr-net-d-car-uses4-public-docker-registry-e62e/mawari-node:latest 190 | ``` 191 | 192 | --- 193 | 194 | ## 🔍 Monitoring & Management 195 | 196 | ### Check Node Status 197 | ```bash 198 | # View running containers 199 | docker ps | grep mawari-node 200 | 201 | # View logs 202 | docker logs mawari-node 203 | 204 | # Monitor resources 205 | docker stats mawari-node 206 | ``` 207 | 208 | ### Screen Session Management 209 | ```bash 210 | # List all screen sessions 211 | screen -ls 212 | 213 | # Reattach to specific session 214 | screen -r mawari 215 | 216 | # Kill a screen session 217 | screen -XS mawari quit 218 | ``` 219 | 220 | --- 221 | 222 | ## 🛡️ Best Practices 223 | 224 | 1. **Always use screen sessions** for persistent node operation 225 | 2. **Never share private keys** - displayed with clear warnings 226 | 3. **Regularly check node status** using option 6 227 | 4. **Keep backups** of important files in `~/mawari/` 228 | 5. **Monitor resource usage** with `docker stats` 229 | 6. **Update regularly** by pulling the latest repository changes 230 | 231 | --- 232 | 233 | ## 🤝 Contributing 234 | 235 | We welcome contributions! Please follow these steps: 236 | 237 | 1. Fork the repository 238 | 2. Create your feature branch: `git checkout -b feature/AmazingFeature` 239 | 3. Commit your changes: `git commit -m 'Add some AmazingFeature'` 240 | 4. Push to the branch: `git push origin feature/AmazingFeature` 241 | 5. Open a Pull Request 242 | 243 | --- 244 | 245 | ## 📄 License 246 | 247 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. 248 | 249 | --- 250 | 251 | ## 🙏 Acknowledgments 252 | 253 | - [Mawari Network](https://mawari.net/) for the Guardian Node implementation 254 | - [Docker](https://www.docker.com/) for containerization technology 255 | - [Web3.py](https://web3py.readthedocs.io/) for Ethereum integration 256 | - The open-source community for various tools and libraries 257 | 258 | --- 259 | 260 | ## 👨‍💻 Author 261 | 262 | **Pourya** 263 | - GitHub: [xPOURY4](https://github.com/xPOURY4) 264 | - Twitter: [TheRealPourya](https://twitter.com/TheRealPourya) 265 | 266 | --- 267 | 268 |
269 | If you found this project helpful, please consider giving it a ⭐️ on GitHub! 270 |

271 | GitHub stars 272 |
273 | -------------------------------------------------------------------------------- /mawari-setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export LANG=en_US.UTF-8 4 | export LC_ALL=en_US.UTF-8 5 | 6 | RED='\033[0;31m' 7 | GREEN='\033[0;32m' 8 | YELLOW='\033[1;33m' 9 | BLUE='\033[0;34m' 10 | NC='\033[0m' 11 | 12 | WORKDIR="$HOME/mawari" 13 | LOG_FILE="$WORKDIR/setup.log" 14 | GENERATED_WALLETS_LOG="$WORKDIR/generated_wallets.log" 15 | 16 | show_menu() { 17 | clear 18 | echo -e "${BLUE}Mawari Network Guardian Node Setup${NC}" 19 | echo "=================================" 20 | echo "1. Install Dependencies" 21 | echo "2. Create New Wallet" 22 | echo "3. Claim Faucet & Mint 3X NFT" 23 | echo "4. Setup Guardian Node" 24 | echo "5. Check Burner Address" 25 | echo "6. Node Status" 26 | echo "7. Delegate Node" 27 | echo "8. Claim Faucet & Send to Burner" 28 | echo "9. Exit" 29 | echo -n "Please enter your choice [1-9]: " 30 | } 31 | 32 | install_dependencies() { 33 | clear 34 | echo -e "${YELLOW}Installing Dependencies...${NC}" 35 | 36 | echo -e "${YELLOW}Updating system...${NC}" 37 | sudo apt update || { echo -e "${RED}Failed to update system.${NC}"; read -p "Press Enter to continue..."; return 1; } 38 | 39 | echo -e "${YELLOW}Installing Docker...${NC}" 40 | sudo apt install -y docker.io docker-compose || { echo -e "${RED}Failed to install Docker.${NC}"; read -p "Press Enter to continue..."; return 1; } 41 | sudo systemctl start docker || { echo -e "${RED}Failed to start Docker.${NC}"; read -p "Press Enter to continue..."; return 1; } 42 | sudo systemctl enable docker || { echo -e "${RED}Failed to enable Docker.${NC}"; read -p "Press Enter to continue..."; return 1; } 43 | 44 | echo -e "${YELLOW}Installing Screen and other dependencies...${NC}" 45 | sudo apt install -y ca-certificates curl gnupg lsb-release screen python3 python3-pip jq xclip || { echo -e "${RED}Failed to install dependencies.${NC}"; read -p "Press Enter to continue..."; return 1; } 46 | 47 | echo -e "${YELLOW}Installing Python dependencies...${NC}" 48 | pip3 install web3 requests eth-account tabulate tqdm twocaptcha || { echo -e "${RED}Failed to install Python dependencies.${NC}"; read -p "Press Enter to continue..."; return 1; } 49 | 50 | echo -e "${GREEN}Dependencies installed successfully!${NC}" 51 | read -p "Press Enter to continue..." 52 | } 53 | 54 | create_wallet() { 55 | clear 56 | echo -e "${YELLOW}Create New Wallet${NC}" 57 | echo "Please visit the following URL to create a new wallet:" 58 | echo -e "${BLUE}https://testnet.mawari.net/mint${NC}" 59 | echo "After creating the wallet, claim faucet and mint 3X NFT." 60 | echo "Copy your wallet address and private key for the next step." 61 | read -p "Press Enter to continue..." 62 | } 63 | 64 | setup_guardian_node() { 65 | clear 66 | echo -e "${YELLOW}Setting up Guardian Node...${NC}" 67 | 68 | echo -e "${YELLOW}Creating mawari directory...${NC}" 69 | mkdir -p $WORKDIR || { echo -e "${RED}Failed to create mawari directory.${NC}"; read -p "Press Enter to continue..."; return 1; } 70 | cd $WORKDIR || { echo -e "${RED}Failed to change to mawari directory.${NC}"; read -p "Press Enter to continue..."; return 1; } 71 | 72 | echo -e "${YELLOW}Setting node image...${NC}" 73 | export MNTESTNET_IMAGE=us-east4-docker.pkg.dev/mawarinetwork-dev/mwr-net-d-car-uses4-public-docker-registry-e62e/mawari-node:latest 74 | 75 | read -p "Enter your owner wallet address (from NFT mint): " OWNER_ADDRESS 76 | if [ -z "$OWNER_ADDRESS" ]; then 77 | echo -e "${RED}Owner address cannot be empty.${NC}" 78 | read -p "Press Enter to continue..." 79 | return 1 80 | fi 81 | export OWNER_ADDRESS 82 | 83 | echo -e "${YELLOW}Starting Guardian Node...${NC}" 84 | docker run --pull always -v $WORKDIR:/app/cache -e OWNERS_ALLOWLIST=$OWNER_ADDRESS $MNTESTNET_IMAGE || { echo -e "${RED}Failed to start Guardian Node.${NC}"; read -p "Press Enter to continue..."; return 1; } 85 | 86 | echo -e "${GREEN}Guardian Node setup completed!${NC}" 87 | read -p "Press Enter to continue..." 88 | } 89 | 90 | check_burner_address() { 91 | clear 92 | echo -e "${YELLOW}Checking Burner Address...${NC}" 93 | 94 | if [ ! -f "$WORKDIR/flohive-cache.json" ]; then 95 | echo -e "${RED}Burner address file not found. Make sure the node is running.${NC}" 96 | read -p "Press Enter to continue..." 97 | return 1 98 | fi 99 | 100 | # Extract burner address and private key 101 | BURNER_ADDRESS=$(cat $WORKDIR/flohive-cache.json | jq -r '.burnerWallet.address') 102 | BURNER_PRIVATE_KEY=$(cat $WORKDIR/flohive-cache.json | jq -r '.burnerWallet.privateKey') 103 | 104 | if [ -z "$BURNER_ADDRESS" ] || [ "$BURNER_ADDRESS" == "null" ]; then 105 | echo -e "${RED}Burner address not found in cache file.${NC}" 106 | read -p "Press Enter to continue..." 107 | return 1 108 | fi 109 | 110 | echo -e "${GREEN}Burner Wallet Information:${NC}" 111 | echo "================================" 112 | echo -e "${BLUE}Address:${NC} $BURNER_ADDRESS" 113 | echo -e "${BLUE}Private Key:${NC} $BURNER_PRIVATE_KEY" 114 | echo "================================" 115 | echo -e "${RED}WARNING: Never share your private key with anyone!${NC}" 116 | echo "" 117 | 118 | # Save burner address to a file for later use 119 | echo "$BURNER_ADDRESS" > $WORKDIR/burner_address.txt 120 | echo "$BURNER_PRIVATE_KEY" > $WORKDIR/burner_private_key.txt 121 | 122 | # Copy to clipboard if xclip is available 123 | if command -v xclip &> /dev/null; then 124 | echo -n "$BURNER_ADDRESS" | xclip -selection clipboard 125 | echo -e "${GREEN}Burner address copied to clipboard!${NC}" 126 | 127 | echo -n "$BURNER_PRIVATE_KEY" | xclip -selection clipboard 128 | echo -e "${GREEN}Private key copied to clipboard!${NC}" 129 | fi 130 | 131 | echo -e "${YELLOW}Please send 1 Faucet Mawari from your NFT wallet to the burner address above.${NC}" 132 | read -p "Press Enter to continue..." 133 | } 134 | 135 | check_node_status() { 136 | clear 137 | echo -e "${YELLOW}Checking Node Status...${NC}" 138 | 139 | if ! docker info > /dev/null 2>&1; then 140 | echo -e "${RED}Docker is not running. Please start Docker.${NC}" 141 | read -p "Press Enter to continue..." 142 | return 1 143 | fi 144 | 145 | if docker ps | grep -q "mawari-node"; then 146 | echo -e "${GREEN}Mawari Guardian Node is running.${NC}" 147 | docker ps | grep "mawari-node" 148 | else 149 | echo -e "${RED}Mawari Guardian Node is not running.${NC}" 150 | echo -e "${YELLOW}Please run the setup process first.${NC}" 151 | fi 152 | 153 | read -p "Press Enter to continue..." 154 | } 155 | 156 | delegate_node() { 157 | clear 158 | echo -e "${YELLOW}Delegating Node...${NC}" 159 | 160 | echo "Please follow these steps to delegate your node:" 161 | echo "1. Visit: ${BLUE}https://app.testnet.mawari.net/${NC}" 162 | echo "2. Connect the wallet you used to mint NFT" 163 | echo "3. Select 3 IDs" 164 | echo "4. Delegate" 165 | echo "5. Enter the burner address" 166 | echo "6. Confirm the transaction" 167 | echo "7. Check if the node is running properly" 168 | 169 | read -p "Press Enter to continue..." 170 | } 171 | 172 | create_claim_bot() { 173 | clear 174 | echo -e "${YELLOW}Creating Mawari Claim Bot...${NC}" 175 | 176 | mkdir -p $WORKDIR/bot 177 | cd $WORKDIR/bot 178 | 179 | cat > mawari_claim_bot.py << 'EOF' 180 | #!/usr/bin/env python3 181 | """ 182 | Mawari Claim Bot 183 | Automated bot for claiming funds from Mawari faucet and sending MAWARI tokens 184 | """ 185 | 186 | import json 187 | import time 188 | import random 189 | import requests 190 | from web3 import Web3 191 | from eth_account import Account 192 | import sys 193 | import os 194 | from datetime import datetime, timedelta 195 | 196 | class MawariClaimBot: 197 | def __init__(self): 198 | self.faucet_url = "https://hub.testnet.mawari.net/api/trpc/faucet.requestFaucetFunds?batch=1" 199 | self.rpc_url = "http://rpc.testnet.mawari.net/http" 200 | self.chain_id = 576 201 | self.symbol = "MAWARI" 202 | self.explorer = "explorer.testnet.mawari.net" 203 | self.site_url = "https://hub.testnet.mawari.net" 204 | self.sitekey = "0x4AAAAAAASRorjU_k9HAdVc" # Turnstile sitekey 205 | 206 | self.wallets = [] 207 | self.web3 = None 208 | self.results = { 209 | 'successful': [], 210 | 'failed': [] 211 | } 212 | 213 | def load_credentials(self): 214 | """Load private keys from creds.txt""" 215 | try: 216 | with open('creds.txt', 'r') as f: 217 | lines = f.readlines() 218 | 219 | for line in lines: 220 | line = line.strip() 221 | if ':' in line: 222 | parts = line.split(':', 1) 223 | if len(parts) == 2: 224 | private_key = parts[0].strip() 225 | burner_address = parts[1].strip() 226 | 227 | # Generate wallet address from private key 228 | account = Account.from_key(private_key) 229 | wallet_address = account.address 230 | 231 | self.wallets.append({ 232 | 'private_key': private_key, 233 | 'wallet_address': wallet_address, 234 | 'burner_address': burner_address, 235 | 'account': account 236 | }) 237 | 238 | if not self.wallets: 239 | print("❌ No valid wallets found in creds.txt") 240 | return False 241 | 242 | print(f"✅ Loaded {len(self.wallets)} wallets") 243 | return True 244 | 245 | except FileNotFoundError: 246 | print("❌ File creds.txt not found") 247 | return False 248 | except Exception as e: 249 | print(f"❌ Error loading creds.txt: {e}") 250 | return False 251 | 252 | def init_web3(self): 253 | """Initialize Web3 connection""" 254 | try: 255 | self.web3 = Web3(Web3.HTTPProvider(self.rpc_url)) 256 | if self.web3.is_connected(): 257 | print(f"✅ Connected to RPC: {self.rpc_url}") 258 | return True 259 | else: 260 | print("❌ Failed to connect to RPC") 261 | return False 262 | except Exception as e: 263 | print(f"❌ Error connecting to RPC: {e}") 264 | return False 265 | 266 | def make_faucet_request(self, wallet_address): 267 | """Send request to faucet""" 268 | print("Please complete the captcha manually at:") 269 | print(f"{self.site_url}") 270 | print(f"And request faucet for address: {wallet_address}") 271 | 272 | input("Press Enter after you've completed the faucet request...") 273 | 274 | # For simplicity, we'll assume the faucet request was successful 275 | # In a real implementation, you would automate the captcha solving 276 | return {'success': True, 'tx_hash': 'manual_tx_' + str(int(time.time()))} 277 | 278 | def send_mawari_token(self, wallet, burner_address): 279 | """Send 1 MAWARI token to burner address""" 280 | try: 281 | # Get nonce 282 | nonce = self.web3.eth.get_transaction_count(wallet['wallet_address']) 283 | 284 | # Get current gas price and increase by 20% for reliability 285 | gas_price = self.web3.eth.gas_price 286 | gas_price = int(gas_price * 1.2) # Increase by 20% 287 | 288 | # Create transaction to send 1 MAWARI (1 * 10^18 wei) 289 | amount = self.web3.to_wei(1, 'ether') 290 | 291 | transaction = { 292 | 'to': burner_address, 293 | 'value': amount, 294 | 'gas': 21000, 295 | 'gasPrice': gas_price, 296 | 'nonce': nonce, 297 | 'chainId': self.chain_id 298 | } 299 | 300 | # Sign transaction 301 | signed_txn = self.web3.eth.account.sign_transaction(transaction, wallet['private_key']) 302 | 303 | # Send transaction 304 | tx_hash = self.web3.eth.send_raw_transaction(signed_txn.rawTransaction) 305 | 306 | return {'success': True, 'tx_hash': tx_hash.hex()} 307 | 308 | except Exception as e: 309 | return {'success': False, 'error': str(e)} 310 | 311 | def process_wallet(self, wallet): 312 | """Process one wallet""" 313 | wallet_address = wallet['wallet_address'] 314 | burner_address = wallet['burner_address'] 315 | 316 | print(f"\nProcessing wallet: {wallet_address[:10]}...") 317 | 318 | # Try to request funds from faucet 319 | faucet_result = self.make_faucet_request(wallet_address) 320 | 321 | if not faucet_result['success']: 322 | self.results['failed'].append({ 323 | 'wallet': wallet_address, 324 | 'burner': burner_address, 325 | 'error': 'Faucet failed' 326 | }) 327 | return 328 | 329 | faucet_tx = faucet_result['tx_hash'] 330 | print(f"✅ Faucet request completed: {faucet_tx}") 331 | 332 | # If faucet request was successful, send MAWARI token 333 | send_result = self.send_mawari_token(wallet, burner_address) 334 | 335 | if send_result['success']: 336 | send_tx = send_result['tx_hash'] 337 | print(f"✅ Send transaction: {send_tx}") 338 | self.results['successful'].append({ 339 | 'wallet': wallet_address, 340 | 'burner': burner_address, 341 | 'faucet_tx': faucet_tx, 342 | 'send_tx': send_tx 343 | }) 344 | else: 345 | error_msg = send_result['error'] 346 | print(f"❌ Send failed: {error_msg}") 347 | self.results['failed'].append({ 348 | 'wallet': wallet_address, 349 | 'burner': burner_address, 350 | 'faucet_tx': faucet_tx, 351 | 'error': f'Send failed: {error_msg}' 352 | }) 353 | 354 | def run(self): 355 | """Main method to run the bot""" 356 | print("🚀 Running Mawari Claim Bot") 357 | print("=" * 50) 358 | 359 | # Load credentials 360 | if not self.load_credentials(): 361 | return False 362 | 363 | # Initialize Web3 364 | if not self.init_web3(): 365 | return False 366 | 367 | print(f"\n📊 Processing {len(self.wallets)} wallets...") 368 | print("=" * 50) 369 | 370 | # Process each wallet 371 | for wallet in self.wallets: 372 | self.process_wallet(wallet) 373 | time.sleep(1) # Pause between wallets 374 | 375 | # Show results 376 | self.show_results() 377 | return True 378 | 379 | def show_results(self): 380 | """Show results""" 381 | print("\n" + "=" * 80) 382 | print("📋 RESULTS") 383 | print("=" * 80) 384 | 385 | # Successful wallets 386 | if self.results['successful']: 387 | print(f"\n✅ SUCCESSFUL ({len(self.results['successful'])}):") 388 | for result in self.results['successful']: 389 | print(f"Wallet: {result['wallet']}") 390 | print(f"Burner: {result['burner']}") 391 | print(f"Faucet TX: {result['faucet_tx']}") 392 | print(f"Send TX: {result['send_tx']}") 393 | print(f"Explorer: https://{self.explorer}/tx/{result['send_tx']}") 394 | print("-" * 50) 395 | 396 | # Failed wallets 397 | if self.results['failed']: 398 | print(f"\n❌ FAILED ({len(self.results['failed'])}):") 399 | for result in self.results['failed']: 400 | print(f"Wallet: {result['wallet']}") 401 | print(f"Burner: {result['burner']}") 402 | print(f"Faucet TX: {result.get('faucet_tx', 'N/A')}") 403 | print(f"Error: {result['error']}") 404 | print("-" * 50) 405 | 406 | print(f"\n📊 Total: {len(self.results['successful'])} successful, {len(self.results['failed'])} failed") 407 | print("=" * 80) 408 | 409 | def main(): 410 | """Main function""" 411 | bot = MawariClaimBot() 412 | bot.run() 413 | 414 | if __name__ == "__main__": 415 | main() 416 | EOF 417 | 418 | chmod +x mawari_claim_bot.py 419 | echo -e "${GREEN}Mawari Claim Bot created successfully!${NC}" 420 | read -p "Press Enter to continue..." 421 | } 422 | 423 | setup_claim_bot() { 424 | clear 425 | echo -e "${YELLOW}Setting up Mawari Claim Bot...${NC}" 426 | 427 | if [ ! -d "$WORKDIR/bot" ]; then 428 | create_claim_bot 429 | fi 430 | 431 | cd $WORKDIR/bot 432 | 433 | # Check if creds.txt exists 434 | if [ ! -f "creds.txt" ]; then 435 | echo -e "${YELLOW}Creating creds.txt file...${NC}" 436 | touch creds.txt 437 | echo "Please add your wallet private key and burner address to creds.txt" 438 | echo "Format: private_key:burner_address" 439 | echo "Example: 0x123abc...:0x456def..." 440 | read -p "Press Enter to continue..." 441 | 442 | # Open creds.txt for editing 443 | nano creds.txt 444 | fi 445 | 446 | # Run the bot 447 | echo -e "${YELLOW}Running Mawari Claim Bot...${NC}" 448 | python3 mawari_claim_bot.py 449 | 450 | read -p "Press Enter to continue..." 451 | } 452 | 453 | generate_burner_wallets() { 454 | clear 455 | echo -e "${YELLOW}Generating Burner Wallets...${NC}" 456 | 457 | mkdir -p $WORKDIR 458 | echo "Generated Burner Wallets:" > "$GENERATED_WALLETS_LOG" 459 | echo "--------------------------" >> "$GENERATED_WALLETS_LOG" 460 | 461 | read -p "Enter the number of burner wallets to generate: " NUM_WALLETS 462 | if ! [[ "$NUM_WALLETS" =~ ^[0-9]+$ ]] || [ "$NUM_WALLETS" -le 0 ]; then 463 | echo -e "${RED}Invalid number of wallets.${NC}" 464 | read -p "Press Enter to continue..." 465 | return 1 466 | fi 467 | 468 | # Check if Node.js is installed 469 | if ! command -v node &> /dev/null; then 470 | echo -e "${YELLOW}Installing Node.js...${NC}" 471 | curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - 472 | sudo apt-get install -y nodejs 473 | fi 474 | 475 | # Check if ethers is installed 476 | if ! npm list ethers &> /dev/null; then 477 | echo -e "${YELLOW}Installing ethers.js...${NC}" 478 | npm install ethers 479 | fi 480 | 481 | for i in $(seq 1 $NUM_WALLETS); do 482 | wallet_dir=$WORKDIR/wallet_${i} 483 | config_file=${wallet_dir}/flohive-cache.json 484 | 485 | echo -e "${YELLOW}Generating wallet #${i}...${NC}" 486 | mkdir -p "$wallet_dir" 487 | 488 | wallet_json=$(node < "$config_file" <> "$GENERATED_WALLETS_LOG" 514 | echo " Burner Address: ${burner_address}" >> "$GENERATED_WALLETS_LOG" 515 | echo "" >> "$GENERATED_WALLETS_LOG" 516 | done 517 | 518 | echo "" 519 | echo -e "${GREEN}Burner wallet generation completed. Details saved to ${GENERATED_WALLETS_LOG}${NC}" 520 | read -p "Press Enter to continue..." 521 | } 522 | 523 | auto_start_nodes() { 524 | clear 525 | echo -e "${YELLOW}Auto-starting Mawari Nodes...${NC}" 526 | 527 | if [ ! -d "$WORKDIR" ]; then 528 | echo -e "${RED}Mawari directory not found. Please run setup first.${NC}" 529 | read -p "Press Enter to continue..." 530 | return 1 531 | fi 532 | 533 | wallet_dirs=$(find $WORKDIR -mindepth 1 -maxdepth 1 -type d -name "wallet_*") 534 | if [ -z "$wallet_dirs" ]; then 535 | echo -e "${RED}No wallet directories found. Please generate burner wallets first.${NC}" 536 | read -p "Press Enter to continue..." 537 | return 1 538 | fi 539 | 540 | read -p "Enter owner address for allowlist: " OWNER_ADDRESS 541 | if [ -z "$OWNER_ADDRESS" ]; then 542 | echo -e "${RED}Owner address cannot be empty.${NC}" 543 | read -p "Press Enter to continue..." 544 | return 1 545 | fi 546 | 547 | export MNTESTNET_IMAGE=us-east4-docker.pkg.dev/mawarinetwork-dev/mwr-net-d-car-uses4-public-docker-registry-e62e/mawari-node:latest 548 | 549 | for dir in $wallet_dirs; do 550 | wallet_index=$(basename "$dir" | sed 's/wallet_//') 551 | container_name="mawari-node-${wallet_index}" 552 | 553 | echo -e "${YELLOW}Checking Node #${wallet_index}...${NC}" 554 | 555 | if docker ps | grep -q "$container_name"; then 556 | echo -e "${GREEN}Container ${container_name} is already running.${NC}" 557 | else 558 | echo -e "${YELLOW}Starting container ${container_name}...${NC}" 559 | docker rm -f "$container_name" 2>/dev/null || true 560 | 561 | docker run -d \ 562 | --name "$container_name" \ 563 | --pull always \ 564 | -v "${dir}:/app/cache" \ 565 | -e OWNERS_ALLOWLIST="$OWNER_ADDRESS" \ 566 | $MNTESTNET_IMAGE 567 | 568 | echo -e "${GREEN}Container ${container_name} started.${NC}" 569 | sleep 3 570 | fi 571 | done 572 | 573 | echo "" 574 | echo -e "${GREEN}Auto-start process completed. Check status with 'docker ps'${NC}" 575 | read -p "Press Enter to continue..." 576 | } 577 | 578 | while true 579 | do 580 | show_menu 581 | read choice 582 | 583 | case $choice in 584 | 1) install_dependencies ;; 585 | 2) create_wallet ;; 586 | 3) create_wallet ;; 587 | 4) setup_guardian_node ;; 588 | 5) check_burner_address ;; 589 | 6) check_node_status ;; 590 | 7) delegate_node ;; 591 | 8) setup_claim_bot ;; 592 | 9) echo -e "${GREEN}Exiting...${NC}"; exit 0 ;; 593 | *) echo -e "${RED}Invalid choice. Please try again.${NC}"; sleep 1 ;; 594 | esac 595 | done 596 | -------------------------------------------------------------------------------- /mawari-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export LANG=en_US.UTF-8 4 | export LC_ALL=en_US.UTF-8 5 | 6 | RED='\033[0;31m' 7 | GREEN='\033[0;32m' 8 | YELLOW='\033[1;33m' 9 | BLUE='\033[0;34m' 10 | NC='\033[0m' 11 | 12 | WORKDIR="$HOME/mawari" 13 | LOG_FILE="$WORKDIR/setup.log" 14 | GENERATED_WALLETS_LOG="$WORKDIR/generated_wallets.log" 15 | 16 | show_menu() { 17 | clear 18 | echo -e "${BLUE}Mawari Network Guardian Node Setup${NC}" 19 | echo "=================================" 20 | echo "1. Install Dependencies" 21 | echo "2. Create New Wallet" 22 | echo "3. Claim Faucet & Mint 3X NFT" 23 | echo "4. Setup Guardian Node" 24 | echo "5. Check Burner Address" 25 | echo "6. Node Status" 26 | echo "7. Delegate Node" 27 | echo "8. Claim Faucet & Send to Burner" 28 | echo "9. Exit" 29 | echo -n "Please enter your choice [1-9]: " 30 | } 31 | 32 | install_dependencies() { 33 | clear 34 | echo -e "${YELLOW}Installing Dependencies...${NC}" 35 | 36 | echo -e "${YELLOW}Updating system...${NC}" 37 | sudo apt update || { echo -e "${RED}Failed to update system.${NC}"; read -p "Press Enter to continue..."; return 1; } 38 | 39 | echo -e "${YELLOW}Installing Docker...${NC}" 40 | sudo apt install -y docker.io docker-compose || { echo -e "${RED}Failed to install Docker.${NC}"; read -p "Press Enter to continue..."; return 1; } 41 | sudo systemctl start docker || { echo -e "${RED}Failed to start Docker.${NC}"; read -p "Press Enter to continue..."; return 1; } 42 | sudo systemctl enable docker || { echo -e "${RED}Failed to enable Docker.${NC}"; read -p "Press Enter to continue..."; return 1; } 43 | 44 | echo -e "${YELLOW}Installing Screen and other dependencies...${NC}" 45 | sudo apt install -y ca-certificates curl gnupg lsb-release screen python3 python3-pip jq xclip || { echo -e "${RED}Failed to install dependencies.${NC}"; read -p "Press Enter to continue..."; return 1; } 46 | 47 | echo -e "${YELLOW}Installing Python dependencies...${NC}" 48 | pip3 install web3 requests eth-account tabulate tqdm twocaptcha || { echo -e "${RED}Failed to install Python dependencies.${NC}"; read -p "Press Enter to continue..."; return 1; } 49 | 50 | echo -e "${GREEN}Dependencies installed successfully!${NC}" 51 | read -p "Press Enter to continue..." 52 | } 53 | 54 | create_wallet() { 55 | clear 56 | echo -e "${YELLOW}Create New Wallet${NC}" 57 | echo "Please visit the following URL to create a new wallet:" 58 | echo -e "${BLUE}https://testnet.mawari.net/mint${NC}" 59 | echo "After creating the wallet, claim faucet and mint 3X NFT." 60 | echo "Copy your wallet address and private key for the next step." 61 | read -p "Press Enter to continue..." 62 | } 63 | 64 | setup_guardian_node() { 65 | clear 66 | echo -e "${YELLOW}Setting up Guardian Node...${NC}" 67 | 68 | echo -e "${YELLOW}Creating mawari directory...${NC}" 69 | mkdir -p $WORKDIR || { echo -e "${RED}Failed to create mawari directory.${NC}"; read -p "Press Enter to continue..."; return 1; } 70 | cd $WORKDIR || { echo -e "${RED}Failed to change to mawari directory.${NC}"; read -p "Press Enter to continue..."; return 1; } 71 | 72 | echo -e "${YELLOW}Setting node image...${NC}" 73 | export MNTESTNET_IMAGE=us-east4-docker.pkg.dev/mawarinetwork-dev/mwr-net-d-car-uses4-public-docker-registry-e62e/mawari-node:latest 74 | 75 | read -p "Enter your owner wallet address (from NFT mint): " OWNER_ADDRESS 76 | if [ -z "$OWNER_ADDRESS" ]; then 77 | echo -e "${RED}Owner address cannot be empty.${NC}" 78 | read -p "Press Enter to continue..." 79 | return 1 80 | fi 81 | export OWNER_ADDRESS 82 | 83 | echo -e "${YELLOW}Starting Guardian Node...${NC}" 84 | docker run --pull always -v $WORKDIR:/app/cache -e OWNERS_ALLOWLIST=$OWNER_ADDRESS $MNTESTNET_IMAGE || { echo -e "${RED}Failed to start Guardian Node.${NC}"; read -p "Press Enter to continue..."; return 1; } 85 | 86 | echo -e "${GREEN}Guardian Node setup completed!${NC}" 87 | read -p "Press Enter to continue..." 88 | } 89 | 90 | check_burner_address() { 91 | clear 92 | echo -e "${YELLOW}Checking Burner Address...${NC}" 93 | 94 | if [ ! -f "$WORKDIR/flohive-cache.json" ]; then 95 | echo -e "${RED}Burner address file not found. Make sure the node is running.${NC}" 96 | read -p "Press Enter to continue..." 97 | return 1 98 | fi 99 | 100 | # Extract burner address and private key 101 | BURNER_ADDRESS=$(cat $WORKDIR/flohive-cache.json | jq -r '.burnerWallet.address') 102 | BURNER_PRIVATE_KEY=$(cat $WORKDIR/flohive-cache.json | jq -r '.burnerWallet.privateKey') 103 | 104 | if [ -z "$BURNER_ADDRESS" ] || [ "$BURNER_ADDRESS" == "null" ]; then 105 | echo -e "${RED}Burner address not found in cache file.${NC}" 106 | read -p "Press Enter to continue..." 107 | return 1 108 | fi 109 | 110 | echo -e "${GREEN}Burner Wallet Information:${NC}" 111 | echo "================================" 112 | echo -e "${BLUE}Address:${NC} $BURNER_ADDRESS" 113 | echo -e "${BLUE}Private Key:${NC} $BURNER_PRIVATE_KEY" 114 | echo "================================" 115 | echo -e "${RED}WARNING: Never share your private key with anyone!${NC}" 116 | echo "" 117 | 118 | # Save burner address to a file for later use 119 | echo "$BURNER_ADDRESS" > $WORKDIR/burner_address.txt 120 | echo "$BURNER_PRIVATE_KEY" > $WORKDIR/burner_private_key.txt 121 | 122 | # Copy to clipboard if xclip is available 123 | if command -v xclip &> /dev/null; then 124 | echo -n "$BURNER_ADDRESS" | xclip -selection clipboard 125 | echo -e "${GREEN}Burner address copied to clipboard!${NC}" 126 | 127 | echo -n "$BURNER_PRIVATE_KEY" | xclip -selection clipboard 128 | echo -e "${GREEN}Private key copied to clipboard!${NC}" 129 | fi 130 | 131 | echo -e "${YELLOW}Please send 1 Faucet Mawari from your NFT wallet to the burner address above.${NC}" 132 | read -p "Press Enter to continue..." 133 | } 134 | 135 | check_node_status() { 136 | clear 137 | echo -e "${YELLOW}Checking Node Status...${NC}" 138 | 139 | if ! docker info > /dev/null 2>&1; then 140 | echo -e "${RED}Docker is not running. Please start Docker.${NC}" 141 | read -p "Press Enter to continue..." 142 | return 1 143 | fi 144 | 145 | if docker ps | grep -q "mawari-node"; then 146 | echo -e "${GREEN}Mawari Guardian Node is running.${NC}" 147 | docker ps | grep "mawari-node" 148 | else 149 | echo -e "${RED}Mawari Guardian Node is not running.${NC}" 150 | echo -e "${YELLOW}Please run the setup process first.${NC}" 151 | fi 152 | 153 | read -p "Press Enter to continue..." 154 | } 155 | 156 | delegate_node() { 157 | clear 158 | echo -e "${YELLOW}Delegating Node...${NC}" 159 | 160 | echo "Please follow these steps to delegate your node:" 161 | echo "1. Visit: ${BLUE}https://app.testnet.mawari.net/${NC}" 162 | echo "2. Connect the wallet you used to mint NFT" 163 | echo "3. Select 3 IDs" 164 | echo "4. Delegate" 165 | echo "5. Enter the burner address" 166 | echo "6. Confirm the transaction" 167 | echo "7. Check if the node is running properly" 168 | 169 | read -p "Press Enter to continue..." 170 | } 171 | 172 | create_claim_bot() { 173 | clear 174 | echo -e "${YELLOW}Creating Mawari Claim Bot...${NC}" 175 | 176 | mkdir -p $WORKDIR/bot 177 | cd $WORKDIR/bot 178 | 179 | cat > mawari_claim_bot.py << 'EOF' 180 | #!/usr/bin/env python3 181 | """ 182 | Mawari Claim Bot 183 | Automated bot for claiming funds from Mawari faucet and sending MAWARI tokens 184 | """ 185 | 186 | import json 187 | import time 188 | import random 189 | import requests 190 | from web3 import Web3 191 | from eth_account import Account 192 | import sys 193 | import os 194 | from datetime import datetime, timedelta 195 | 196 | class MawariClaimBot: 197 | def __init__(self): 198 | self.faucet_url = "https://hub.testnet.mawari.net/api/trpc/faucet.requestFaucetFunds?batch=1" 199 | self.rpc_url = "http://rpc.testnet.mawari.net/http" 200 | self.chain_id = 576 201 | self.symbol = "MAWARI" 202 | self.explorer = "explorer.testnet.mawari.net" 203 | self.site_url = "https://hub.testnet.mawari.net" 204 | self.sitekey = "0x4AAAAAAASRorjU_k9HAdVc" # Turnstile sitekey 205 | 206 | self.wallets = [] 207 | self.web3 = None 208 | self.results = { 209 | 'successful': [], 210 | 'failed': [] 211 | } 212 | 213 | def load_credentials(self): 214 | """Load private keys from creds.txt""" 215 | try: 216 | with open('creds.txt', 'r') as f: 217 | lines = f.readlines() 218 | 219 | for line in lines: 220 | line = line.strip() 221 | if ':' in line: 222 | parts = line.split(':', 1) 223 | if len(parts) == 2: 224 | private_key = parts[0].strip() 225 | burner_address = parts[1].strip() 226 | 227 | # Generate wallet address from private key 228 | account = Account.from_key(private_key) 229 | wallet_address = account.address 230 | 231 | self.wallets.append({ 232 | 'private_key': private_key, 233 | 'wallet_address': wallet_address, 234 | 'burner_address': burner_address, 235 | 'account': account 236 | }) 237 | 238 | if not self.wallets: 239 | print("❌ No valid wallets found in creds.txt") 240 | return False 241 | 242 | print(f"✅ Loaded {len(self.wallets)} wallets") 243 | return True 244 | 245 | except FileNotFoundError: 246 | print("❌ File creds.txt not found") 247 | return False 248 | except Exception as e: 249 | print(f"❌ Error loading creds.txt: {e}") 250 | return False 251 | 252 | def init_web3(self): 253 | """Initialize Web3 connection""" 254 | try: 255 | self.web3 = Web3(Web3.HTTPProvider(self.rpc_url)) 256 | if self.web3.is_connected(): 257 | print(f"✅ Connected to RPC: {self.rpc_url}") 258 | return True 259 | else: 260 | print("❌ Failed to connect to RPC") 261 | return False 262 | except Exception as e: 263 | print(f"❌ Error connecting to RPC: {e}") 264 | return False 265 | 266 | def make_faucet_request(self, wallet_address): 267 | """Send request to faucet""" 268 | print("Please complete the captcha manually at:") 269 | print(f"{self.site_url}") 270 | print(f"And request faucet for address: {wallet_address}") 271 | 272 | input("Press Enter after you've completed the faucet request...") 273 | 274 | # For simplicity, we'll assume the faucet request was successful 275 | # In a real implementation, you would automate the captcha solving 276 | return {'success': True, 'tx_hash': 'manual_tx_' + str(int(time.time()))} 277 | 278 | def send_mawari_token(self, wallet, burner_address): 279 | """Send 1 MAWARI token to burner address""" 280 | try: 281 | # Get nonce 282 | nonce = self.web3.eth.get_transaction_count(wallet['wallet_address']) 283 | 284 | # Get current gas price and increase by 20% for reliability 285 | gas_price = self.web3.eth.gas_price 286 | gas_price = int(gas_price * 1.2) # Increase by 20% 287 | 288 | # Create transaction to send 1 MAWARI (1 * 10^18 wei) 289 | amount = self.web3.to_wei(1, 'ether') 290 | 291 | transaction = { 292 | 'to': burner_address, 293 | 'value': amount, 294 | 'gas': 21000, 295 | 'gasPrice': gas_price, 296 | 'nonce': nonce, 297 | 'chainId': self.chain_id 298 | } 299 | 300 | # Sign transaction 301 | signed_txn = self.web3.eth.account.sign_transaction(transaction, wallet['private_key']) 302 | 303 | # Send transaction 304 | tx_hash = self.web3.eth.send_raw_transaction(signed_txn.rawTransaction) 305 | 306 | return {'success': True, 'tx_hash': tx_hash.hex()} 307 | 308 | except Exception as e: 309 | return {'success': False, 'error': str(e)} 310 | 311 | def process_wallet(self, wallet): 312 | """Process one wallet""" 313 | wallet_address = wallet['wallet_address'] 314 | burner_address = wallet['burner_address'] 315 | 316 | print(f"\nProcessing wallet: {wallet_address[:10]}...") 317 | 318 | # Try to request funds from faucet 319 | faucet_result = self.make_faucet_request(wallet_address) 320 | 321 | if not faucet_result['success']: 322 | self.results['failed'].append({ 323 | 'wallet': wallet_address, 324 | 'burner': burner_address, 325 | 'error': 'Faucet failed' 326 | }) 327 | return 328 | 329 | faucet_tx = faucet_result['tx_hash'] 330 | print(f"✅ Faucet request completed: {faucet_tx}") 331 | 332 | # If faucet request was successful, send MAWARI token 333 | send_result = self.send_mawari_token(wallet, burner_address) 334 | 335 | if send_result['success']: 336 | send_tx = send_result['tx_hash'] 337 | print(f"✅ Send transaction: {send_tx}") 338 | self.results['successful'].append({ 339 | 'wallet': wallet_address, 340 | 'burner': burner_address, 341 | 'faucet_tx': faucet_tx, 342 | 'send_tx': send_tx 343 | }) 344 | else: 345 | error_msg = send_result['error'] 346 | print(f"❌ Send failed: {error_msg}") 347 | self.results['failed'].append({ 348 | 'wallet': wallet_address, 349 | 'burner': burner_address, 350 | 'faucet_tx': faucet_tx, 351 | 'error': f'Send failed: {error_msg}' 352 | }) 353 | 354 | def run(self): 355 | """Main method to run the bot""" 356 | print("🚀 Running Mawari Claim Bot") 357 | print("=" * 50) 358 | 359 | # Load credentials 360 | if not self.load_credentials(): 361 | return False 362 | 363 | # Initialize Web3 364 | if not self.init_web3(): 365 | return False 366 | 367 | print(f"\n📊 Processing {len(self.wallets)} wallets...") 368 | print("=" * 50) 369 | 370 | # Process each wallet 371 | for wallet in self.wallets: 372 | self.process_wallet(wallet) 373 | time.sleep(1) # Pause between wallets 374 | 375 | # Show results 376 | self.show_results() 377 | return True 378 | 379 | def show_results(self): 380 | """Show results""" 381 | print("\n" + "=" * 80) 382 | print("📋 RESULTS") 383 | print("=" * 80) 384 | 385 | # Successful wallets 386 | if self.results['successful']: 387 | print(f"\n✅ SUCCESSFUL ({len(self.results['successful'])}):") 388 | for result in self.results['successful']: 389 | print(f"Wallet: {result['wallet']}") 390 | print(f"Burner: {result['burner']}") 391 | print(f"Faucet TX: {result['faucet_tx']}") 392 | print(f"Send TX: {result['send_tx']}") 393 | print(f"Explorer: https://{self.explorer}/tx/{result['send_tx']}") 394 | print("-" * 50) 395 | 396 | # Failed wallets 397 | if self.results['failed']: 398 | print(f"\n❌ FAILED ({len(self.results['failed'])}):") 399 | for result in self.results['failed']: 400 | print(f"Wallet: {result['wallet']}") 401 | print(f"Burner: {result['burner']}") 402 | print(f"Faucet TX: {result.get('faucet_tx', 'N/A')}") 403 | print(f"Error: {result['error']}") 404 | print("-" * 50) 405 | 406 | print(f"\n📊 Total: {len(self.results['successful'])} successful, {len(self.results['failed'])} failed") 407 | print("=" * 80) 408 | 409 | def main(): 410 | """Main function""" 411 | bot = MawariClaimBot() 412 | bot.run() 413 | 414 | if __name__ == "__main__": 415 | main() 416 | EOF 417 | 418 | chmod +x mawari_claim_bot.py 419 | echo -e "${GREEN}Mawari Claim Bot created successfully!${NC}" 420 | read -p "Press Enter to continue..." 421 | } 422 | 423 | setup_claim_bot() { 424 | clear 425 | echo -e "${YELLOW}Setting up Mawari Claim Bot...${NC}" 426 | 427 | if [ ! -d "$WORKDIR/bot" ]; then 428 | create_claim_bot 429 | fi 430 | 431 | cd $WORKDIR/bot 432 | 433 | # Check if creds.txt exists 434 | if [ ! -f "creds.txt" ]; then 435 | echo -e "${YELLOW}Creating creds.txt file...${NC}" 436 | touch creds.txt 437 | echo "Please add your wallet private key and burner address to creds.txt" 438 | echo "Format: private_key:burner_address" 439 | echo "Example: 0x123abc...:0x456def..." 440 | read -p "Press Enter to continue..." 441 | 442 | # Open creds.txt for editing 443 | nano creds.txt 444 | fi 445 | 446 | # Run the bot 447 | echo -e "${YELLOW}Running Mawari Claim Bot...${NC}" 448 | python3 mawari_claim_bot.py 449 | 450 | read -p "Press Enter to continue..." 451 | } 452 | 453 | generate_burner_wallets() { 454 | clear 455 | echo -e "${YELLOW}Generating Burner Wallets...${NC}" 456 | 457 | mkdir -p $WORKDIR 458 | echo "Generated Burner Wallets:" > "$GENERATED_WALLETS_LOG" 459 | echo "--------------------------" >> "$GENERATED_WALLETS_LOG" 460 | 461 | read -p "Enter the number of burner wallets to generate: " NUM_WALLETS 462 | if ! [[ "$NUM_WALLETS" =~ ^[0-9]+$ ]] || [ "$NUM_WALLETS" -le 0 ]; then 463 | echo -e "${RED}Invalid number of wallets.${NC}" 464 | read -p "Press Enter to continue..." 465 | return 1 466 | fi 467 | 468 | # Check if Node.js is installed 469 | if ! command -v node &> /dev/null; then 470 | echo -e "${YELLOW}Installing Node.js...${NC}" 471 | curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - 472 | sudo apt-get install -y nodejs 473 | fi 474 | 475 | # Check if ethers is installed 476 | if ! npm list ethers &> /dev/null; then 477 | echo -e "${YELLOW}Installing ethers.js...${NC}" 478 | npm install ethers 479 | fi 480 | 481 | for i in $(seq 1 $NUM_WALLETS); do 482 | wallet_dir=$WORKDIR/wallet_${i} 483 | config_file=${wallet_dir}/flohive-cache.json 484 | 485 | echo -e "${YELLOW}Generating wallet #${i}...${NC}" 486 | mkdir -p "$wallet_dir" 487 | 488 | wallet_json=$(node < "$config_file" <> "$GENERATED_WALLETS_LOG" 514 | echo " Burner Address: ${burner_address}" >> "$GENERATED_WALLETS_LOG" 515 | echo "" >> "$GENERATED_WALLETS_LOG" 516 | done 517 | 518 | echo "" 519 | echo -e "${GREEN}Burner wallet generation completed. Details saved to ${GENERATED_WALLETS_LOG}${NC}" 520 | read -p "Press Enter to continue..." 521 | } 522 | 523 | auto_start_nodes() { 524 | clear 525 | echo -e "${YELLOW}Auto-starting Mawari Nodes...${NC}" 526 | 527 | if [ ! -d "$WORKDIR" ]; then 528 | echo -e "${RED}Mawari directory not found. Please run setup first.${NC}" 529 | read -p "Press Enter to continue..." 530 | return 1 531 | fi 532 | 533 | wallet_dirs=$(find $WORKDIR -mindepth 1 -maxdepth 1 -type d -name "wallet_*") 534 | if [ -z "$wallet_dirs" ]; then 535 | echo -e "${RED}No wallet directories found. Please generate burner wallets first.${NC}" 536 | read -p "Press Enter to continue..." 537 | return 1 538 | fi 539 | 540 | read -p "Enter owner address for allowlist: " OWNER_ADDRESS 541 | if [ -z "$OWNER_ADDRESS" ]; then 542 | echo -e "${RED}Owner address cannot be empty.${NC}" 543 | read -p "Press Enter to continue..." 544 | return 1 545 | fi 546 | 547 | export MNTESTNET_IMAGE=us-east4-docker.pkg.dev/mawarinetwork-dev/mwr-net-d-car-uses4-public-docker-registry-e62e/mawari-node:latest 548 | 549 | for dir in $wallet_dirs; do 550 | wallet_index=$(basename "$dir" | sed 's/wallet_//') 551 | container_name="mawari-node-${wallet_index}" 552 | 553 | echo -e "${YELLOW}Checking Node #${wallet_index}...${NC}" 554 | 555 | if docker ps | grep -q "$container_name"; then 556 | echo -e "${GREEN}Container ${container_name} is already running.${NC}" 557 | else 558 | echo -e "${YELLOW}Starting container ${container_name}...${NC}" 559 | docker rm -f "$container_name" 2>/dev/null || true 560 | 561 | docker run -d \ 562 | --name "$container_name" \ 563 | --pull always \ 564 | -v "${dir}:/app/cache" \ 565 | -e OWNERS_ALLOWLIST="$OWNER_ADDRESS" \ 566 | $MNTESTNET_IMAGE 567 | 568 | echo -e "${GREEN}Container ${container_name} started.${NC}" 569 | sleep 3 570 | fi 571 | done 572 | 573 | echo "" 574 | echo -e "${GREEN}Auto-start process completed. Check status with 'docker ps'${NC}" 575 | read -p "Press Enter to continue..." 576 | } 577 | 578 | while true 579 | do 580 | show_menu 581 | read choice 582 | 583 | case $choice in 584 | 1) install_dependencies ;; 585 | 2) create_wallet ;; 586 | 3) create_wallet ;; 587 | 4) setup_guardian_node ;; 588 | 5) check_burner_address ;; 589 | 6) check_node_status ;; 590 | 7) delegate_node ;; 591 | 8) setup_claim_bot ;; 592 | 9) echo -e "${GREEN}Exiting...${NC}"; exit 0 ;; 593 | *) echo -e "${RED}Invalid choice. Please try again.${NC}"; sleep 1 ;; 594 | esac 595 | done 596 | --------------------------------------------------------------------------------