sol-safekey 0.1.1

A powerful command-line tool for secure Solana key management with Triple-Factor 2FA
Documentation

📑 Table of Contents


✨ Features

  • 🔐 AES-256 Encryption: Military-grade encryption with PBKDF2 key derivation
  • 🤖 Bot Integration: Simple 3-line integration for Solana trading bots
  • 💰 Solana Operations: Built-in support for transfers, wrapping, token operations, PumpSwap DEX sell, and Pump.fun internal market (bonding curve) sell
  • 🔒 Secure by Default: Password via stdin pipe (memory only, never environment variables)
  • 🎯 Interactive CLI: Full-featured command-line interface with safekey command

🚀 Quick Start

For Bot Developers

# Build the bot
cargo build --example bot_example --features solana-ops --release

# Run interactive safekey commands
./build-cache/release/examples/bot_example safekey

As a Library

use sol_safekey::KeyManager;

// Generate keypair
let keypair = KeyManager::generate_keypair();

// Encrypt and save
let json = KeyManager::keypair_to_encrypted_json(&keypair, "password")?;
std::fs::write("keystore.json", json)?;

// Load and decrypt
let json = std::fs::read_to_string("keystore.json")?;
let keypair = KeyManager::keypair_from_encrypted_json(&json, "password")?;

📚 Documentation

🔐 Security

  • Password Security: stdin pipe only (never in environment variables or files)
  • Encryption: AES-256 with PBKDF2 key derivation
  • Memory Safety: Immediate password cleanup after use

📦 Installation

Add to your Cargo.toml:

[dependencies]
sol-safekey = { path = "path/to/sol-safekey" }

[features]
solana-ops = ["sol-safekey/solana-ops"]

🛠️ Available Operations

Wallet Management

  • Create Wallet - Generate new encrypted wallet with AES-256
  • Import Wallet - Import existing wallet from private key or seed phrase
  • Export Wallet - Export wallet to encrypted JSON format
  • View Address - Display wallet public address

SOL Operations

  • Query Balance - Check SOL balance in your wallet
  • Transfer SOL - Send SOL to other addresses
  • Wrap SOL - Convert SOL to WSOL (Wrapped SOL)
  • Unwrap WSOL - Convert WSOL back to SOL

Token Operations

  • Transfer SPL Tokens - Send SPL tokens to other addresses
  • Query Token Balance - Check token balances
  • 🔥 PumpSwap Sell - Interactive token selling on PumpSwap DEX
    • Batch Selling: Sell multiple tokens at once (comma or space separated)
    • Smart Defaults: Seed optimization and confirmations default to yes
    • One-click Sell: Automatically sell all token balance
    • Seed-optimized ATA: Lower transaction fees (enabled by default)
    • 99% Slippage: Fast execution even in volatile markets
    • Token-2022 Support: Automatic detection and handling
    • Bilingual UI: Full support for English and Chinese
  • 🔥 Pump.fun Internal Market Sell - One-click sell on Pump.fun bonding curve (internal market only; for migrated tokens use PumpSwap)
    • Internal market (bonding curve): Sell tokens that are still on Pump.fun’s bonding curve for native SOL
    • Seed-optimized ATA: Lower fees (optional, same as PumpSwap)
    • Token-2022 Support: Automatic detection
    • Bilingual UI: English and Chinese

Advanced Features

  • Durable Nonce Accounts - Create and manage nonce accounts for offline signing
  • 2FA Support - Optional two-factor authentication for enhanced security
  • Hardware Fingerprint - Device-based security layer
  • Secure Password Input - stdin pipe only (never in environment variables)

📖 Examples

See examples/bot_example.rs for a complete bot integration example.

🤝 Contributing

Contributions welcome! Please ensure security best practices are followed. Use English for commit and PR descriptions.

📄 License

MIT License - See LICENSE file for details