decharge-scout 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.example ADDED
@@ -0,0 +1,18 @@
1
+ # EIA API Key (Required - Get from https://www.eia.gov/opendata/register.php)
2
+ EIA_API_KEY=your_eia_api_key_here
3
+
4
+ # Solana Configuration
5
+ SOLANA_NETWORK=devnet
6
+ SOLANA_RPC_URL=https://api.devnet.solana.com
7
+
8
+ # Mock Oracle Escrow Address (Replace with your test wallet for demo)
9
+ ORACLE_ESCROW_ADDRESS=YourDevWalletPublicKeyHere
10
+
11
+ # Dashboard API (Optional - for testing dashboard integration)
12
+ DASHBOARD_API_URL=http://localhost:3000/submit
13
+
14
+ # Stake Amount (in SOL)
15
+ STAKE_AMOUNT=0.01
16
+
17
+ # Premium Feature Price (in SOL)
18
+ PREMIUM_PRICE=0.001
package/README.md ADDED
@@ -0,0 +1,323 @@
1
+ # DeCharge Scout
2
+
3
+ AI-powered energy grid data scout with Solana blockchain integration. This CLI tool scouts public energy grid data, performs optimizations to find the cheapest EV charging windows, and submits anonymized results to a mock DeCharge oracle on Solana.
4
+
5
+ ## 🚀 Quick Install
6
+
7
+ **One-liner installation:**
8
+
9
+ ```bash
10
+ git clone -b claude/solana-energy-scout-cli-d7vYT https://github.com/sentinelcore/agentone.git decharge-scout && cd decharge-scout && node setup.js
11
+ ```
12
+
13
+ Then run: `decharge-scout`
14
+
15
+ [See more installation options →](ONE_COMMAND_INSTALL.md)
16
+
17
+ ## Features
18
+
19
+ - **Real-time Energy Data**: Fetches live energy pricing and demand data from EIA and Electricity Maps APIs
20
+ - **Smart Optimization**: Finds the cheapest charging windows in the next 24 hours
21
+ - **Blockchain Integration**: Submits results to Solana devnet with anti-spam staking
22
+ - **Points System**: Earn points for successful submissions and good optimizations
23
+ - **Location Tracking**: Auto-detects location via IP for global dashboard visualization
24
+ - **Premium Features**: x402 micropayments for enhanced forecast data
25
+ - **Dashboard Ready**: Structured data output for global visualization
26
+
27
+ ## Prerequisites
28
+
29
+ - Node.js v20 or higher
30
+ - A Solana wallet keypair file (JSON format)
31
+ - EIA API key (free from https://www.eia.gov/opendata/register.php)
32
+ - At least 0.02 SOL in your devnet wallet for staking + fees
33
+
34
+ ## Installation
35
+
36
+ ### One-Command Setup (Recommended)
37
+
38
+ The easiest way to get started:
39
+
40
+ ```bash
41
+ cd decharge-scout
42
+ node setup.js
43
+ ```
44
+
45
+ This interactive script will:
46
+ - ✅ Install all dependencies
47
+ - ✅ Generate a wallet (or use existing)
48
+ - ✅ Request devnet SOL airdrop
49
+ - ✅ Configure your .env file
50
+ - ✅ Install globally (optional)
51
+
52
+ **That's it!** After setup completes, just run:
53
+
54
+ ```bash
55
+ decharge-scout
56
+ ```
57
+
58
+ ### Manual Installation (Alternative)
59
+
60
+ If you prefer manual setup:
61
+
62
+ #### 1. Install dependencies
63
+
64
+ ```bash
65
+ npm install
66
+ ```
67
+
68
+ #### 2. Configure environment
69
+
70
+ ```bash
71
+ cp .env.example .env
72
+ # Edit .env and add your EIA_API_KEY from https://www.eia.gov/opendata/register.php
73
+ ```
74
+
75
+ #### 3. Create wallet
76
+
77
+ ```bash
78
+ solana-keygen new --outfile ./wallet.json
79
+ ```
80
+
81
+ #### 4. Fund wallet
82
+
83
+ ```bash
84
+ solana airdrop 1 $(solana-keygen pubkey ./wallet.json) --url devnet
85
+ ```
86
+
87
+ #### 5. Install globally (optional)
88
+
89
+ ```bash
90
+ npm install -g .
91
+ ```
92
+
93
+ ## Usage
94
+
95
+ ### Basic Usage (Auto-configuration)
96
+
97
+ After running `node setup.js`, simply:
98
+
99
+ ```bash
100
+ decharge-scout
101
+ ```
102
+
103
+ The CLI will automatically:
104
+ - Use `./wallet.json` if no wallet specified
105
+ - Create a new wallet if none exists
106
+ - Prompt for EIA API key if missing
107
+ - Auto-detect your location
108
+
109
+ ### With Custom Options
110
+
111
+ ```bash
112
+ decharge-scout --wallet=./my-wallet.json --agent-name="MyEnergyAgent"
113
+ ```
114
+
115
+ ### With Manual Location
116
+
117
+ ```bash
118
+ decharge-scout --agent-name="MyAgent" --location="Austin, TX"
119
+ ```
120
+
121
+ ### With Premium Features
122
+
123
+ ```bash
124
+ decharge-scout --premium
125
+ ```
126
+
127
+ ### All Options
128
+
129
+ ```bash
130
+ decharge-scout --help
131
+
132
+ Options:
133
+ -w, --wallet <path> Path to Solana wallet JSON keypair file (default: ./wallet.json)
134
+ -a, --agent-name <name> Custom agent name (default: auto-generated)
135
+ -l, --location <location> Manual location override (default: auto-detect via IP)
136
+ -p, --premium Enable premium features (x402 micropayments)
137
+ -h, --help Display help for command
138
+ -V, --version Output the version number
139
+ ```
140
+
141
+ ## How It Works
142
+
143
+ ### 1. Onboarding (1-2 mins)
144
+
145
+ - Loads your Solana wallet
146
+ - Stakes 0.01 SOL to escrow (refunded on exit)
147
+ - Detects your location via IP
148
+ - Initializes points tracking
149
+
150
+ ### 2. Query Cycle (Every 15 mins)
151
+
152
+ - Fetches energy pricing data from EIA (ERCOT) or Electricity Maps
153
+ - Analyzes data to find cheapest charging window
154
+ - Calculates savings vs average and peak prices
155
+
156
+ ### 3. Optimization & Submit
157
+
158
+ - Displays results (e.g., "Cheapest charge: 2AM-3AM at $0.05/kWh, 20% savings")
159
+ - Anonymizes data (hashes agent name, generalizes location)
160
+ - Submits to Solana devnet oracle with transaction proof
161
+ - Logs dashboard-ready JSON structure
162
+ - Optionally POSTs to dashboard API if configured
163
+
164
+ ### 4. Earn & Loop
165
+
166
+ - Awards 1-5 base points per submission
167
+ - Bonus +2 points for >15% savings
168
+ - Saves points locally to `~/.decharge-scout/points.json`
169
+ - Continues running every 15 minutes
170
+
171
+ ### 5. Exit
172
+
173
+ - Press Ctrl+C to stop
174
+ - Refunds stake if runs > 0
175
+ - Displays final points and stats
176
+
177
+ ## Dashboard Integration
178
+
179
+ Each submission creates a structured JSON payload for dashboard visualization:
180
+
181
+ ```json
182
+ {
183
+ "agent_name": "MyAgent",
184
+ "location": "Austin, TX",
185
+ "timestamp": 1234567890,
186
+ "results": {
187
+ "cheapest_window": "2AM-3AM",
188
+ "price": 0.05,
189
+ "savings": 23.5,
190
+ "data_points": 24
191
+ }
192
+ }
193
+ ```
194
+
195
+ To enable dashboard API submission, set in `.env`:
196
+
197
+ ```env
198
+ DASHBOARD_API_URL=http://localhost:3000/submit
199
+ ```
200
+
201
+ The CLI will POST this data to your dashboard backend (optional).
202
+
203
+ ## Premium Features (x402)
204
+
205
+ Premium access provides:
206
+ - Enhanced forecast accuracy
207
+ - Carbon intensity data
208
+ - Renewable energy percentages
209
+ - Confidence scores
210
+ - Extended 48-hour forecasts
211
+
212
+ Cost: 0.001 SOL per access
213
+
214
+ Enable with `--premium` flag. Payment is processed via x402 micropayment every 3rd run.
215
+
216
+ ## Project Structure
217
+
218
+ ```
219
+ decharge-scout/
220
+ ├── index.js # Main CLI entry point
221
+ ├── package.json # Dependencies and metadata
222
+ ├── .env.example # Environment variables template
223
+ ├── README.md # This file
224
+ ├── src/
225
+ │ ├── wallet.js # Solana wallet operations
226
+ │ ├── energy-data.js # Energy API integrations
227
+ │ ├── optimizer.js # Optimization algorithms
228
+ │ ├── oracle.js # Solana oracle submission
229
+ │ ├── points.js # Points tracking system
230
+ │ ├── geolocation.js # IP-based location detection
231
+ │ └── x402.js # x402 micropayment handling
232
+ ```
233
+
234
+ ## API Data Sources
235
+
236
+ ### Primary: EIA API (ERCOT)
237
+ - Endpoint: `https://api.eia.gov/v2/electricity/rto/region-data/data/`
238
+ - Provides: Real-time demand and pricing for Texas (ERCOT)
239
+ - Requires: Free API key from https://www.eia.gov/opendata/register.php
240
+
241
+ ### Secondary: Electricity Maps
242
+ - Endpoint: `https://api.electricitymaps.com/v3/power-breakdown/latest`
243
+ - Provides: Power grid forecasts and carbon intensity
244
+ - Free tier available
245
+
246
+ ### Fallback: Mock Data
247
+ - Generated locally if APIs are unavailable
248
+ - Simulates realistic daily pricing patterns
249
+
250
+ ## Points System
251
+
252
+ - **Base Points**: 1-5 per successful submission
253
+ - **Bonus Points**: +2 for >15% savings optimization
254
+ - **Storage**: Local file at `~/.decharge-scout/points.json`
255
+ - **Persistence**: Points carry across sessions
256
+
257
+ ## Security & Privacy
258
+
259
+ - **No Hardcoded Keys**: All sensitive data in `.env` or prompts
260
+ - **Anonymization**: Agent names are hashed, locations generalized
261
+ - **Refundable Stake**: Your 0.01 SOL stake is refunded on exit
262
+ - **Local-First**: Points stored locally, not on-chain
263
+ - **Devnet Only**: Uses Solana devnet (test network)
264
+
265
+ ## Troubleshooting
266
+
267
+ ### "EIA_API_KEY not set"
268
+ Get your free API key from https://www.eia.gov/opendata/register.php and add to `.env`
269
+
270
+ ### "Insufficient balance"
271
+ Fund your devnet wallet:
272
+ ```bash
273
+ solana airdrop 1 <YOUR_WALLET_ADDRESS> --url devnet
274
+ ```
275
+
276
+ ### "All data sources failed"
277
+ - Check your internet connection
278
+ - Verify EIA API key is valid
279
+ - Try again (fallback mock data will be used)
280
+
281
+ ### "Oracle submission failed"
282
+ - Ensure wallet has enough SOL for transaction fees
283
+ - Check Solana devnet status
284
+ - Mock transactions will be created as fallback
285
+
286
+ ## Development
287
+
288
+ ### Run in dev mode
289
+
290
+ ```bash
291
+ npm start -- --wallet=./wallet.json
292
+ ```
293
+
294
+ ### Test with mock dashboard
295
+
296
+ Start a simple server to receive dashboard submissions:
297
+
298
+ ```bash
299
+ # In another terminal
300
+ node -e "require('http').createServer((req,res)=>{let body='';req.on('data',d=>body+=d);req.on('end',()=>{console.log(JSON.parse(body));res.end('OK')})}).listen(3000)"
301
+ ```
302
+
303
+ Then set in `.env`:
304
+ ```env
305
+ DASHBOARD_API_URL=http://localhost:3000/submit
306
+ ```
307
+
308
+ ## Contributing
309
+
310
+ This is a proof-of-concept demo. For production use:
311
+ - Implement actual Solana program for oracle (not just memo transactions)
312
+ - Add SPL token minting for points instead of local storage
313
+ - Integrate with real x402 payment providers
314
+ - Add more energy grid APIs (GridStatus.io, etc.)
315
+ - Implement proper payment channel state management
316
+
317
+ ## License
318
+
319
+ MIT
320
+
321
+ ## Disclaimer
322
+
323
+ This is a demo application for educational purposes. Do not use with mainnet wallets or real funds. Energy data is for informational purposes only and should not be used as financial advice.