A Python package for managing blockchain accounts and interactions with REST APIs.
Project description
t8386
A comprehensive Python utility library with logger, base classes for account processing, and various helper functions for blockchain and web development.
Installation
pip install t8386
Quick Start
from t8386 import Logger
# Basic logging
Logger.log_info("This is an info message")
Logger.log_error("This is an error message")
Logger.log_success("This is a success message")
Logger.log_warning("This is a warning message")
Logger.log_debug("This is a debug message")
Logger.log("This is a generic message")
Logger.log_hana("This is a HANA style message")
# Utils
from t8386 import Utils
email_variations = Utils.generate_gmail("john.doe@gmail.com", multiple_dot=True, maximum=50)
Core Components
1. Logger
Colored logging utility with timestamps for better debugging and monitoring.
from t8386 import Logger
Logger.log_info("Application started")
Logger.log_success("Operation completed successfully")
Logger.log_error("An error occurred")
Logger.log_warning("This is a warning")
Logger.log_debug("Debug information")
Logger.log("Generic message")
Logger.log_hana("HANA style message")
Log Levels:
log_info()- Blue colored info messageslog_error()- Red colored error messageslog_success()- Green colored success messageslog_warning()- Yellow colored warning messageslog_debug()- Cyan colored debug messageslog()- Generic messages without colorlog_hana()- Magenta colored HANA style messages
2. Base Classes for Account Processing
BaseAccount
Abstract base class for managing user accounts with session handling.
from t8386 import BaseAccount
class MyAccount(BaseAccount):
def __init__(self, wallet_address, wallet_private_key, **kwargs):
super().__init__(wallet_address, wallet_private_key, **kwargs)
def to_dict(self):
data = super().to_dict()
# Add custom fields
return data
# Usage
account = MyAccount(
wallet_address="0x123...",
wallet_private_key="0xabc...",
x_auth_token="token123",
proxy="http://proxy:port"
)
# Session management
session = await account.get_session()
await account.close_session()
BaseProcessor
Abstract base class for processing multiple accounts with threading support.
from t8386 import BaseProcessor, BaseAccount
import asyncio
class MyProcessor(BaseProcessor):
def __init__(self):
super().__init__(table_name="my_accounts", file_proxy="proxies.txt")
async def process_single_account(self, account: BaseAccount):
# Implement your account processing logic
Logger.log_info(f"Processing {account}")
# Your custom logic here
await self.save_account(account)
# Usage
processor = MyProcessor()
account = await processor.prepare_account()
await processor.process_single_account(account)
BaseRest
Base REST client with common HTTP functionality and Twitter integration.
from t8386 import BaseRest, BaseRestConfig, BaseAccount
class MyRestClient(BaseRest):
def __init__(self):
config = BaseRestConfig(
site="https://example.com",
base_url="https://api.example.com"
)
super().__init__(config)
async def get_header_before_request(self, account: BaseAccount):
return {"Authorization": f"Bearer {account.x_auth_token}"}
# Usage
client = MyRestClient()
session = await client.before_request(account)
response_data = await client.handle_response(response)
BaseRestConfig
Configuration class for REST clients.
from t8386 import BaseRestConfig
config = BaseRestConfig(
site="https://example.com",
base_url="https://api.example.com/v1",
headers={"User-Agent": "MyApp/1.0"}
)
3. Utilities
Email Generation
Generate Gmail address variations for testing and automation.
from t8386 import Utils
# Generate simple variations
variations = Utils.generate_gmail("john.doe@gmail.com")
# Output: ['j.ohn.doe@gmail.com', 'jo.hn.doe@gmail.com', ...]
# Generate with multiple dots and uppercase
variations = Utils.generate_gmail(
"john.doe@gmail.com",
multiple_dot=True,
allow_uppercase=True,
maximum=100
)
JWT Token Handling
Decode and validate JWT tokens.
from t8386 import Utils
token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
# Check if token is valid
if Utils.jwt_is_valid(token):
payload = Utils.jwt_to_dict(token)
Logger.log_success(f"Token valid, expires: {payload.get('exp')}")
else:
Logger.log_error("Token expired or invalid")
# Alternative validation
is_valid = Utils.check_jwt_token_validity(token)
File Operations
Read various file formats with error handling.
from t8386 import Utils
# Read text files
lines = Utils.read_file("data.txt")
# Read JSON files
config = Utils.read_file_json("config.json")
# Read CSV files
data = Utils.read_file_csv("users.csv")
# Read proof data with filtering
proof_data = Utils.read_proof_data() # Reads proof.txt and filters used items
# Append data to file
Utils.append_to_file("log.txt", "New log entry")
Proxy Management
Handle proxy lists and test connectivity.
from t8386 import Utils
# Load proxy list
proxies = Utils.get_proxy_list("proxies.txt")
# Get working proxy with retries
working_proxy = Utils.retry_get_proxy(proxies, retries=5)
# Test proxy connectivity
if Utils.check_live_proxy("http://user:pass@proxy:port"):
Logger.log_success("Proxy is working")
# Format proxy string
proxy_str = Utils.proxy_to_str({"host": "proxy.com", "port": 8080})
Random Generators
Generate various random data for testing.
from t8386 import Utils
# Generate usernames
username = Utils.random_username(length=15)
prefixed_username = Utils.random_username_with_prefix(length=20)
# Generate API credentials
api_key, api_secret = Utils.generate_api_keys()
# Generate unique identifiers
nonce = Utils.generate_nonce(16)
uuid_str = Utils.generate_uuid()
Cookie and Data Utilities
Extract and process various data formats.
from t8386 import Utils
# Extract cookie values
auth_token = Utils.extract_cookie_value("session=abc; auth_token=xyz", "auth_token")
# Extract auth tokens from files
tokens = Utils.extract_auth_tokens("tokens.json")
# Data type conversions
result = Utils.tuple_to_int((1, 2, 3))
boolean = Utils.tuple_to_bool((True, False))
4. Wallet Utilities
Ethereum Wallet Generation
Generate and manage Ethereum wallets.
from t8386 import Wallet, generate_wallet, personal_sign, recover
# Generate new wallet
wallet = generate_wallet()
print(f"Address: {wallet.address}")
print(f"Private Key: {wallet.private_key}")
print(f"Mnemonic: {wallet.mnemonic}")
# Sign messages
message = "Hello Ethereum!"
signature = personal_sign(message, wallet.private_key)
# Recover signer
recovered_address = recover(message, signature)
print(f"Recovered address: {recovered_address}")
TRON Wallet Support
Generate and manage TRON wallets.
from t8386 import generate_tron_wallet, tron_sign_message, verify_tron_signature
# Generate TRON wallet
tron_wallet = generate_tron_wallet()
print(f"TRON Address: {tron_wallet.address}")
# Sign TRON messages
signature = tron_sign_message("Hello TRON!", tron_wallet.private_key)
# Verify signature
is_valid = verify_tron_signature("Hello TRON!", signature, tron_wallet.address)
5. Database Integration
Supabase Database
Built-in Supabase integration for data persistence.
from t8386 import SupabseDB
# Initialize database
db = SupabseDB(url="your-url", key="your-key")
# Or use environment variables
# db = SupabseDB() # Uses SUPABASE_URL and SUPABASE_KEY
# Database operations
data = db.get_data("accounts")
db.insert_data("accounts", {"wallet_address": "0x123...", "balance": 100})
db.update_data("accounts", {"id": 1, "balance": 200}, key_eq="id")
db.delete_data("accounts", "id", "1")
# Bulk operations
db.insert_data_bulk("accounts", [
{"wallet_address": "0x123...", "balance": 100},
{"wallet_address": "0x456...", "balance": 200}
])
Complete Example
Here's a complete example showing how to use the library components together:
import asyncio
from t8386 import (
BaseProcessor, BaseAccount, BaseRest, BaseRestConfig,
Logger, Utils, generate_wallet
)
class MyAccount(BaseAccount):
def __init__(self, wallet_address, wallet_private_key, **kwargs):
super().__init__(wallet_address, wallet_private_key, **kwargs)
self.email = kwargs.get('email')
self.username = kwargs.get('username')
def to_dict(self):
data = super().to_dict()
data.update({
'email': self.email,
'username': self.username
})
return data
class MyRestClient(BaseRest):
def __init__(self):
config = BaseRestConfig(
site="https://example.com",
base_url="https://api.example.com/v1"
)
super().__init__(config)
async def get_header_before_request(self, account: BaseAccount):
return {"Authorization": f"Bearer {account.x_auth_token}"}
class MyProcessor(BaseProcessor):
def __init__(self):
super().__init__(table_name="my_accounts", file_proxy="proxies.txt")
self.rest = MyRestClient()
async def process_single_account(self, account: MyAccount):
Logger.log_info(f"Processing account: {account}")
# Get session with proxy
session = await self.rest.before_request(account)
# Make API calls
async with session.get("/user/profile") as response:
result = await self.rest.handle_response(response)
if result:
Logger.log_success(f"Profile retrieved for {account}")
# Save to database
await self.save_account(account)
async def create_new_account(self):
# Generate wallet
wallet = generate_wallet()
# Generate account details
email_variations = Utils.generate_gmail("test@gmail.com", maximum=1)
username = Utils.random_username()
# Create account
account = MyAccount(
wallet_address=wallet.address,
wallet_private_key=wallet.private_key,
email=email_variations[0] if email_variations else None,
username=username,
proxy=self.prepare_proxy()
)
return account
async def main():
processor = MyProcessor()
# Create and process new account
account = await processor.create_new_account()
await processor.process_single_account(account)
Logger.log_success("Processing completed!")
if __name__ == "__main__":
asyncio.run(main())
Configuration Files
proxies.txt
ip1:port1:user1:pass1
ip2:port2:user2:pass2
ip3:port3
Environment Variables
Create a .env file:
SUPABASE_URL=your-supabase-url
SUPABASE_KEY=your-supabase-key
API Reference
Logger Methods
| Method | Description | Color |
|---|---|---|
log_info(message) |
Info messages | Blue |
log_error(message) |
Error messages | Red |
log_success(message) |
Success messages | Green |
log_warning(message) |
Warning messages | Yellow |
log_debug(message) |
Debug messages | Cyan |
log(message) |
Generic messages | Default |
log_hana(message) |
HANA style messages | Magenta |
Utils Methods
| Category | Method | Description |
|---|---|---|
generate_gmail(email, multiple_dot, allow_uppercase, maximum) |
Generate Gmail variations | |
| JWT | jwt_to_dict(token), jwt_is_valid(token), check_jwt_token_validity(token) |
JWT handling |
| Files | read_file(path), read_file_json(path), read_file_csv(path), append_to_file(path, data) |
File operations |
| Proxy | get_proxy_list(path), check_live_proxy(proxy), retry_get_proxy(proxies, retries), proxy_to_str(proxy) |
Proxy management |
| Random | random_username(length), random_username_with_prefix(length), generate_uuid(), generate_nonce(length), generate_api_keys() |
Random generators |
| Data | read_proof_data(), extract_auth_tokens(path), extract_cookie_value(cookie_str, key), tuple_to_int(tup), tuple_to_bool(tup) |
Data processing |
Base Classes
BaseAccount
__init__(wallet_address, wallet_private_key, **kwargs)get_session(headers=None, timeout=120)- Get HTTP sessionclose_session()- Close HTTP sessionto_dict()- Convert to dictionary (abstract method)
BaseProcessor
__init__(table_name=None, file_proxy=None)- Initialize processorprepare_account(proxy=None)- Create new accountprepare_proxy()- Get proxy from listprocess_single_account(account)- Process account (abstract)save_account(account)- Save to databaserun_account_thread(account, func_name, **kwargs)- Run in threadafter_process(account)- Cleanup after processing
BaseRest
__init__(config)- Initialize with configbefore_request(account)- Prepare sessionhandle_response(response)- Handle HTTP responseget_header_before_request(account)- Get headers (abstract)get_code_x_connect(account, config)- Twitter integration
BaseRestConfig
__init__(site, base_url, headers=None)- Initialize configurationupdate_headers(token)- Update headers with token
Wallet Functions
generate_wallet()- Generate Ethereum walletpersonal_sign(message, private_key)- Sign messagerecover(message, signature)- Recover signer addressgenerate_tron_wallet()- Generate TRON wallettron_sign_message(message, private_key)- Sign TRON messageverify_tron_signature(message, signature, address)- Verify TRON signature
Database (SupabseDB)
__init__(url=None, key=None)- Initialize with credentialsget_data(table_name, columns="*", **filters)- Get datainsert_data(table_name, data)- Insert single recordinsert_data_bulk(table_name, data_list)- Insert multiple recordsupdate_data(table_name, data, key_eq, key_value=None)- Update recordsdelete_data(table_name, key, value)- Delete records
Requirements
- Python 3.7+
- aiohttp
- colorama
- supabase
- faker
- requests
- web3
- eth-account
- mnemonic
- tronpy
Installation Options
# Basic installation
pip install t8386
# Install with development dependencies
pip install t8386[dev]
# Install from source
git clone https://github.com/tyluu/t8386.git
cd t8386
pip install -e .
Error Handling
The library includes comprehensive error handling:
from t8386 import Logger, Utils
try:
data = Utils.read_file_json("config.json")
except Exception as e:
Logger.log_error(f"Failed to read config: {str(e)}")
# Proxy handling with retries
proxy = Utils.retry_get_proxy(proxies, retries=3)
if not proxy:
Logger.log_warning("No working proxy found")
Best Practices
-
Use async/await for better performance:
async def process_accounts(): for account in accounts: await processor.process_single_account(account)
-
Handle sessions properly:
try: session = await account.get_session() # Use session finally: await account.close_session()
-
Log appropriately:
Logger.log_info("Starting process") Logger.log_success("Process completed") Logger.log_error("Process failed")
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Changelog
v0.1.68
- Initial release
- Logger class with colored output
- Base classes for account processing
- Utils class with comprehensive utility functions
- Wallet utilities for Ethereum and TRON
- Supabase database integration
- Support for email generation, JWT handling, file operations, and proxy management
License
MIT License
Support
For issues and questions, please visit our GitHub repository or contact the maintainers.
Acknowledgments
- Built with modern Python async/await patterns
- Integrates with popular blockchain libraries
- Designed for scalable account processing workflows
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file t8386-0.1.68.tar.gz.
File metadata
- Download URL: t8386-0.1.68.tar.gz
- Upload date:
- Size: 27.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45ae54d4af0a3925290d208422fcc2713dc217863ea610dc9e276ad21cf79612
|
|
| MD5 |
79c82ab7a072e2d6baf17c2d0c30e47a
|
|
| BLAKE2b-256 |
673f6114727a7eb25af704da8feb6e3d950fd4f070f2a91fd19deb2879e7873f
|
File details
Details for the file t8386-0.1.68-py3-none-any.whl.
File metadata
- Download URL: t8386-0.1.68-py3-none-any.whl
- Upload date:
- Size: 25.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbb3f1875155ce9ce0d3a86ef8bb85c47292f62cafb4a2571322ccb5b4e56bab
|
|
| MD5 |
22c60f5644927b37b9a7b1f1d74c9fa7
|
|
| BLAKE2b-256 |
85dd9c2fb47652c562086e7d901d63d605cc50d6621f75856e008d4947f0c4cb
|