@pixeloffice-eu/x402 1.0.2 → 1.0.3
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/README.md +16 -8
- package/index.js +12 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,20 +14,28 @@ npm install @pixeloffice-eu/x402
|
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## ⚡ Quickstart (Zero-Config with .env)
|
|
20
|
+
|
|
21
|
+
Put your agent's Solana key into your `.env`:
|
|
22
|
+
|
|
23
|
+
```env
|
|
24
|
+
# .env
|
|
25
|
+
SOLANA_PRIVATE_KEY=5K2...your_phantom_or_solana_base58_private_key...
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Then in your code:
|
|
18
29
|
|
|
19
30
|
```javascript
|
|
20
31
|
import { PixelRouterX402Client } from '@pixeloffice-eu/x402';
|
|
21
32
|
|
|
22
|
-
//
|
|
23
|
-
const client = new PixelRouterX402Client(
|
|
24
|
-
baseUrl: 'https://api.pixeloffice.eu/v1',
|
|
25
|
-
solanaPrivateKey: process.env.SOLANA_AGENT_PRIVATE_KEY
|
|
26
|
-
});
|
|
33
|
+
// Zero-config: Automatically picks up SOLANA_PRIVATE_KEY from process.env
|
|
34
|
+
const client = new PixelRouterX402Client();
|
|
27
35
|
|
|
28
|
-
// Autonomous LLM invocation with automatic HTTP 402
|
|
36
|
+
// Autonomous LLM invocation with automatic 0.24ms Solana HTTP 402 micro-settlement
|
|
29
37
|
const response = await client.createChatCompletion({
|
|
30
|
-
model: 'blun-auto', // Or 'deepseek-chat', 'claude-3.5-sonnet'
|
|
38
|
+
model: 'blun-auto', // Or 'deepseek-chat', 'claude-3.5-sonnet', 'ox-alpha'
|
|
31
39
|
messages: [
|
|
32
40
|
{ role: 'user', content: 'Execute autonomous codebase refactor.' }
|
|
33
41
|
]
|
package/index.js
CHANGED
|
@@ -79,15 +79,24 @@ class PixelRouterX402Client {
|
|
|
79
79
|
this.sessionId = options.sessionId || null;
|
|
80
80
|
this.customSigner = options.customSigner || null;
|
|
81
81
|
|
|
82
|
+
// Auto-detect private/public key from environment if not explicitly passed
|
|
83
|
+
const envPrivKey = (typeof process !== 'undefined' && process.env) ?
|
|
84
|
+
(process.env.SOLANA_AGENT_PRIVATE_KEY || process.env.SOLANA_PRIVATE_KEY || process.env.SOLANA_KEY || null) : null;
|
|
85
|
+
const resolvedPrivKey = options.solanaPrivateKey || envPrivKey;
|
|
86
|
+
|
|
87
|
+
const envPubKey = (typeof process !== 'undefined' && process.env) ?
|
|
88
|
+
(process.env.SOLANA_AGENT_PUBLIC_KEY || process.env.SOLANA_PUBLIC_KEY || null) : null;
|
|
89
|
+
const resolvedPubKey = options.solanaPublicKey || envPubKey;
|
|
90
|
+
|
|
82
91
|
if (options.keypair && options.keypair.privateKey) {
|
|
83
92
|
this.privateKeyObject = options.keypair.privateKey;
|
|
84
93
|
this.publicKeyObject = options.keypair.publicKey;
|
|
85
94
|
const der = this.publicKeyObject.export({ type: 'spki', format: 'der' });
|
|
86
95
|
this.solanaPublicKey = bs58Encode(der.subarray(12));
|
|
87
|
-
} else if (
|
|
88
|
-
this._initFromPrivateKey(
|
|
96
|
+
} else if (resolvedPrivKey) {
|
|
97
|
+
this._initFromPrivateKey(resolvedPrivKey, resolvedPubKey);
|
|
89
98
|
} else if (options.customSigner) {
|
|
90
|
-
this.solanaPublicKey =
|
|
99
|
+
this.solanaPublicKey = resolvedPubKey || 'custom_signer_wallet';
|
|
91
100
|
} else {
|
|
92
101
|
// Create fresh ephemeral ed25519 keypair for autonomous agent
|
|
93
102
|
const kp = crypto.generateKeyPairSync('ed25519');
|