clawcash 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 openclaw
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,155 @@
1
+ # ClawCash
2
+
3
+ > TypeScript cryptocurrency wallet library for AI agents in the openclaw ecosystem
4
+
5
+ ClawCash is a simple, secure, multi-chain wallet library designed specifically for AI agents. It enables agents to:
6
+
7
+ - Create and manage multi-chain wallet addresses
8
+ - Send and receive cryptocurrency payments
9
+ - Query balances across multiple blockchains
10
+ - Sign messages and transactions
11
+
12
+ ## Features
13
+
14
+ - **Multi-chain support**: Ethereum, Polygon, BSC, Arbitrum, Bitcoin (coming soon)
15
+ - **Simple API**: Designed for AI agents with intuitive function names
16
+ - **Secure**: BIP39/BIP32 key derivation, private key encryption
17
+ - **TypeScript**: Full type safety and excellent IDE support
18
+ - **Agent-friendly**: Clear error messages and simplified interfaces
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ npm install clawcash
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ ### Create a New Wallet
29
+
30
+ ```typescript
31
+ import { createWallet } from 'clawcash';
32
+
33
+ // Create a new wallet (generates mnemonic automatically)
34
+ const wallet = createWallet();
35
+
36
+ // Get addresses for all supported chains
37
+ const addresses = await wallet.getAddresses();
38
+ console.log(addresses);
39
+ // {
40
+ // ethereum: '0x...',
41
+ // polygon: '0x...',
42
+ // bsc: '0x...',
43
+ // arbitrum: '0x...',
44
+ // bitcoin: 'bc1...'
45
+ // }
46
+ ```
47
+
48
+ ### Import Existing Wallet
49
+
50
+ ```typescript
51
+ import { importWallet } from 'clawcash';
52
+
53
+ const mnemonic = 'your twelve word mnemonic phrase here';
54
+ const wallet = importWallet(mnemonic);
55
+ ```
56
+
57
+ ### Check Balance
58
+
59
+ ```typescript
60
+ // Check native token balance
61
+ const balance = await wallet.getBalance('ethereum');
62
+ console.log(balance);
63
+ // { amount: 1000000000000000000n, formatted: '1.0', symbol: 'ETH', decimals: 18 }
64
+ ```
65
+
66
+ ### Send Payment
67
+
68
+ ```typescript
69
+ import { quickSend } from 'clawcash';
70
+
71
+ // Quick send on Ethereum
72
+ const txHash = await quickSend(
73
+ wallet,
74
+ 'ethereum',
75
+ '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
76
+ '0.1' // amount in ETH
77
+ );
78
+ console.log('Transaction hash:', txHash);
79
+ ```
80
+
81
+ ### Estimate Fees
82
+
83
+ ```typescript
84
+ const fee = await wallet.estimateFee({
85
+ chain: 'ethereum',
86
+ from: '0x...',
87
+ to: '0x...',
88
+ amount: '0.1',
89
+ token: 'ETH'
90
+ });
91
+ console.log(`Estimated fee: ${fee.formatted} ETH`);
92
+ ```
93
+
94
+ ## API Reference
95
+
96
+ ### Wallet Operations
97
+
98
+ | Function | Description |
99
+ |----------|-------------|
100
+ | `createWallet(mnemonic?)` | Create new or import wallet |
101
+ | `importWallet(mnemonic)` | Import wallet from mnemonic |
102
+ | `wallet.getAddresses()` | Get all chain addresses |
103
+ | `wallet.getBalance(chain)` | Get balance for chain |
104
+ | `wallet.sendPayment(params)` | Send payment |
105
+ | `wallet.estimateFee(params)` | Estimate transaction fee |
106
+ | `wallet.signMessage(msg, chain)` | Sign a message |
107
+
108
+ ### Supported Chains
109
+
110
+ | Chain | Symbol | Status |
111
+ |-------|--------|--------|
112
+ | Ethereum | ETH | ✅ Implemented |
113
+ | Polygon | MATIC | ✅ Implemented |
114
+ | BSC | BNB | ✅ Implemented |
115
+ | Arbitrum | ETH | ✅ Implemented |
116
+ | Bitcoin | BTC | 🚧 Coming soon |
117
+
118
+ ### Supported Tokens
119
+
120
+ - Native tokens: ETH, MATIC, BNB
121
+ - ERC-20 tokens: USDT, USDC (coming soon)
122
+
123
+ ## Advanced Usage
124
+
125
+ ### Custom RPC URLs
126
+
127
+ ```typescript
128
+ const wallet = createWallet({
129
+ rpcUrls: {
130
+ ethereum: 'https://your-custom-rpc-url.com'
131
+ }
132
+ });
133
+ ```
134
+
135
+ ### Export Mnemonic (Handle with Care!)
136
+
137
+ ```typescript
138
+ const mnemonic = wallet.exportMnemonic();
139
+ console.log('Keep this safe:', mnemonic);
140
+ ```
141
+
142
+ ## Security
143
+
144
+ - Never log or expose private keys or mnemonics
145
+ - Always validate addresses before sending
146
+ - Use environment variables for RPC URLs
147
+ - Implement rate limiting for production use
148
+
149
+ ## License
150
+
151
+ MIT License - see [LICENSE](LICENSE) for details.
152
+
153
+ ## OpenClaw Ecosystem
154
+
155
+ ClawCash is part of the [OpenClaw](https://github.com/openclaw) ecosystem of tools for AI agents.