109 lines
2.7 KiB
Markdown
109 lines
2.7 KiB
Markdown
# PacaBotManager Python Client
|
|
|
|
A Python script to interact with your PacaBotManager contract on BSC mainnet using web3.py.
|
|
|
|
## Setup
|
|
|
|
1. **Install dependencies:**
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
2. **Set up environment variables:**
|
|
Create a `.env` file in the project root:
|
|
```env
|
|
PRIVATE_KEY=your_private_key_here_without_0x_prefix
|
|
```
|
|
|
|
## Usage
|
|
|
|
### Basic Usage
|
|
```bash
|
|
python python_scripts/pacabotmanager_client.py
|
|
```
|
|
|
|
### Available Functions
|
|
|
|
The script provides these main functions:
|
|
|
|
#### 1. View Functions (Read-only)
|
|
```python
|
|
# Get contract owners
|
|
client.get_owner() # Bot manager owner
|
|
client.get_paca_owner() # PACA contract owner
|
|
|
|
# Get user stakes
|
|
stakes = client.get_stakes("0x41970Ce76b656030A79E7C1FA76FC4EB93980255")
|
|
```
|
|
|
|
#### 2. Write Functions (Requires gas fees)
|
|
```python
|
|
# Clear all stakes for a user
|
|
client.clear_stakes("0x41970Ce76b656030A79E7C1FA76FC4EB93980255")
|
|
|
|
# Clear all vestings for a user
|
|
client.clear_vesting("0x41970Ce76b656030A79E7C1FA76FC4EB93980255")
|
|
|
|
# Execute multiple calls atomically
|
|
calls = [
|
|
{
|
|
'target': paca_address,
|
|
'callData': encoded_clear_stakes_call
|
|
},
|
|
{
|
|
'target': paca_address,
|
|
'callData': encoded_clear_vesting_call
|
|
}
|
|
]
|
|
client.multi_call_atomic(calls)
|
|
```
|
|
|
|
## Contract Addresses
|
|
|
|
- **PacaBotManager**: `0x4E5d3cD7743934b61041ba2ac3E9df39a0A26dcC`
|
|
- **PACA BSC**: `0x3fF44D639a4982A4436f6d737430141aBE68b4E1`
|
|
- **Network**: BSC Mainnet (Chain ID: 56)
|
|
|
|
## Safety Notes
|
|
|
|
⚠️ **WARNING**: The `clear_stakes` and `clear_vesting` functions affect real funds on mainnet!
|
|
|
|
- Only the bot manager owner can call these functions
|
|
- Always test on a fork first if possible
|
|
- Double-check user addresses before calling
|
|
- These operations are irreversible
|
|
|
|
## Example Output
|
|
|
|
```
|
|
🐍 PacaBotManager Python Client
|
|
========================================
|
|
🔑 Using account: 0xYourAddress
|
|
💰 Balance: 0.295 BNB
|
|
🤖 PacaBotManager: 0x4E5d3cD7743934b61041ba2ac3E9df39a0A26dcC
|
|
🔗 PACA Contract: 0x3fF44D639a4982A4436f6d737430141aBE68b4E1
|
|
🌐 Network: BSC Mainnet
|
|
|
|
📊 Getting stakes for user: 0x41970Ce76b656030A79E7C1FA76FC4EB93980255
|
|
📈 User has 2 stakes:
|
|
📌 Stake 1:
|
|
Amount: 100.0 ETH
|
|
Complete: False
|
|
Status: 🟢 ACTIVE
|
|
|
|
📌 Stake 2:
|
|
Amount: 20.357851028442383 ETH
|
|
Complete: False
|
|
Status: 🟢 ACTIVE
|
|
|
|
💎 Summary:
|
|
Total Stakes: 2
|
|
Active Stakes: 2
|
|
Total Active Amount: 120.357851028442383 ETH
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
- **"PRIVATE_KEY not found"**: Make sure your `.env` file exists and contains `PRIVATE_KEY=your_key`
|
|
- **Gas estimation failed**: The function might be reverting (not authorized, invalid params, etc.)
|
|
- **Insufficient funds**: Make sure you have enough BNB for gas fees |