chainai 0.0.1 → 0.0.2

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.
Files changed (2) hide show
  1. package/README.md +168 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,3 +1,169 @@
1
- # clawhub-eth-skill
1
+ # chainai
2
2
 
3
- Ethereum skill for clawhub
3
+ A non-interactive CLI tool for Ethereum and EVM-compatible blockchain operations, designed for AI agent consumption. Supports signing, sending, broadcasting transactions, token swaps via 1inch Fusion, balance queries, and wallet generation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npx chainai@latest <command> [options]
9
+ ```
10
+
11
+ Requires Node.js >= 18.
12
+
13
+ ## Authentication
14
+
15
+ All commands that require a private key accept it via:
16
+
17
+ 1. **`-k` flag**: `-k 0xYOUR_PRIVATE_KEY`
18
+ 2. **Environment variable**: `export CHAINAI_PRIVATE_KEY=0xYOUR_PRIVATE_KEY`
19
+
20
+ ## Supported Networks
21
+
22
+ | Network | Chain ID | Aliases |
23
+ | --------------- | -------- | ---------------------------- |
24
+ | Ethereum | 1 | `mainnet`, `ethereum`, `eth` |
25
+ | BNB Smart Chain | 56 | `bsc`, `binance`, `bnb` |
26
+
27
+ ## Commands
28
+
29
+ ### `gen-wallet`
30
+
31
+ Generate a new random wallet.
32
+
33
+ ```bash
34
+ npx chainai@latest gen-wallet
35
+ ```
36
+
37
+ ### `who-am-i`
38
+
39
+ Get the address derived from a private key.
40
+
41
+ ```bash
42
+ npx chainai@latest who-am-i -k 0xYOUR_PRIVATE_KEY
43
+ ```
44
+
45
+ ### `sign-message`
46
+
47
+ Sign a message (EIP-191 personal sign).
48
+
49
+ ```bash
50
+ npx chainai@latest sign-message -k 0xKEY -m "Hello World"
51
+ npx chainai@latest sign-message -k 0xKEY -m 0x68656c6c6f --raw # raw hex
52
+ ```
53
+
54
+ ### `sign`
55
+
56
+ Sign a raw hash (secp256k1, no prefix). **Use with caution** — prefer `sign-message` in most cases.
57
+
58
+ ```bash
59
+ npx chainai@latest sign -k 0xKEY -h 0xHASH
60
+ ```
61
+
62
+ ### `sign-typed-data`
63
+
64
+ Sign EIP-712 typed data.
65
+
66
+ ```bash
67
+ npx chainai@latest sign-typed-data -k 0xKEY -d '{"domain":{...},"types":{...},"primaryType":"...","message":{...}}'
68
+ ```
69
+
70
+ ### `sign-transaction`
71
+
72
+ Sign a transaction (legacy, EIP-2930, or EIP-1559). Returns a serialized signed transaction.
73
+
74
+ ```bash
75
+ npx chainai@latest sign-transaction -k 0xKEY -t '{"to":"0x...","value":"1000000000000000000","gasPrice":"20000000000","gas":"21000","nonce":0,"chainId":1}'
76
+ ```
77
+
78
+ ### `get-balance`
79
+
80
+ Get native or ERC-20 token balances.
81
+
82
+ ```bash
83
+ npx chainai@latest get-balance -a 0xADDRESS # ETH balance
84
+ npx chainai@latest get-balance -a 0xADDRESS -n bsc # BNB balance
85
+ npx chainai@latest get-balance -a 0xADDRESS -t 0xTOKEN_CONTRACT # ERC-20 balance
86
+ npx chainai@latest get-balance -a 0xADDRESS --all # all token balances
87
+ ```
88
+
89
+ ### `send`
90
+
91
+ Build and sign a transaction to send native tokens or ERC-20 tokens. Automatically fetches nonce, gas, and fee data.
92
+
93
+ ```bash
94
+ npx chainai@latest send -k 0xKEY --to 0xRECIPIENT --amount 1.5 -t 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee # send ETH
95
+ npx chainai@latest send -k 0xKEY --to 0xRECIPIENT --amount 100 -t 0xTOKEN_CONTRACT # send ERC-20
96
+ npx chainai@latest send -k 0xKEY --to 0xRECIPIENT --amount 0.5 -t 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee -n bsc # send BNB
97
+ ```
98
+
99
+ ### `broadcast`
100
+
101
+ Broadcast a serialized signed transaction to the network.
102
+
103
+ ```bash
104
+ npx chainai@latest broadcast -s 0xSERIALIZED_TX
105
+ npx chainai@latest broadcast -s 0xSERIALIZED_TX -n bsc
106
+ ```
107
+
108
+ ### `tx-status`
109
+
110
+ Check the status of a transaction by hash.
111
+
112
+ ```bash
113
+ npx chainai@latest tx-status -h 0xTX_HASH
114
+ npx chainai@latest tx-status -h 0xTX_HASH -n bsc
115
+ ```
116
+
117
+ ### `swap`
118
+
119
+ Swap tokens via 1inch Fusion. Use `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee` for native tokens.
120
+
121
+ ```bash
122
+ npx chainai@latest swap -k 0xKEY --from-token 0xFROM --to-token 0xTO --amount 1.5 # get quote
123
+ npx chainai@latest swap -k 0xKEY --from-token 0xFROM --to-token 0xTO --amount 1.5 -y # auto-confirm
124
+ npx chainai@latest swap -k 0xKEY --from-token 0xFROM --to-token 0xTO --amount 0.5 -n bsc # swap on BSC
125
+ ```
126
+
127
+ ### `swap-order-status`
128
+
129
+ Check the status of a 1inch Fusion swap order.
130
+
131
+ ```bash
132
+ npx chainai@latest swap-order-status -k 0xKEY --order-hash 0xORDER_HASH
133
+ ```
134
+
135
+ ## Output Format
136
+
137
+ **Success** messages are written to `stdout`:
138
+
139
+ ```
140
+ CHAINAI_OK: <description>
141
+ { ... }
142
+ ```
143
+
144
+ **Error** messages are written to `stderr`:
145
+
146
+ ```
147
+ CHAINAI_ERR: <ERROR_CODE> — <description>
148
+ ```
149
+
150
+ Error codes: `INVALID_INPUT`, `EXECUTION_FAILED`, `TIMEOUT`, `UNKNOWN`.
151
+
152
+ ## Development
153
+
154
+ ```bash
155
+ yarn build # compile to dist/
156
+ yarn dev # run from source
157
+ yarn test # run tests
158
+ yarn format # format with prettier
159
+ yarn format:check # check formatting
160
+ yarn clean # remove dist/
161
+ ```
162
+
163
+ ## Agent Integration
164
+
165
+ See [agents.md](agents.md) for the complete agent skill reference, including detailed option tables, output schemas, and integration guidelines.
166
+
167
+ ## License
168
+
169
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chainai",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "chainai CLI tool",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",