easctl 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.
Files changed (59) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/README.md +195 -0
  3. package/dist/index.js +31401 -0
  4. package/dist/index.js.map +1 -0
  5. package/manual-test/package-lock.json +4483 -0
  6. package/manual-test/package.json +15 -0
  7. package/package.json +40 -0
  8. package/src/__tests__/chains.test.ts +82 -0
  9. package/src/__tests__/clear-key.test.ts +40 -0
  10. package/src/__tests__/client.test.ts +168 -0
  11. package/src/__tests__/commands/attest.test.ts +203 -0
  12. package/src/__tests__/commands/get-attestation.test.ts +164 -0
  13. package/src/__tests__/commands/multi-attest.test.ts +166 -0
  14. package/src/__tests__/commands/multi-revoke.test.ts +114 -0
  15. package/src/__tests__/commands/multi-timestamp.test.ts +88 -0
  16. package/src/__tests__/commands/offchain-attest.test.ts +217 -0
  17. package/src/__tests__/commands/query-attestation.test.ts +84 -0
  18. package/src/__tests__/commands/query-attestations.test.ts +156 -0
  19. package/src/__tests__/commands/query-schema.test.ts +62 -0
  20. package/src/__tests__/commands/query-schemas.test.ts +110 -0
  21. package/src/__tests__/commands/revoke.test.ts +86 -0
  22. package/src/__tests__/commands/schema-get.test.ts +66 -0
  23. package/src/__tests__/commands/schema-register.test.ts +94 -0
  24. package/src/__tests__/commands/timestamp.test.ts +78 -0
  25. package/src/__tests__/config.test.ts +103 -0
  26. package/src/__tests__/graphql.test.ts +148 -0
  27. package/src/__tests__/integration/graphql-live.test.ts +103 -0
  28. package/src/__tests__/integration/offchain-signing.test.ts +252 -0
  29. package/src/__tests__/integration/schema-encoder.test.ts +131 -0
  30. package/src/__tests__/output.test.ts +138 -0
  31. package/src/__tests__/set-key.test.ts +58 -0
  32. package/src/__tests__/stdin.test.ts +15 -0
  33. package/src/chains.ts +99 -0
  34. package/src/client.ts +53 -0
  35. package/src/commands/attest.ts +73 -0
  36. package/src/commands/clear-key.ts +15 -0
  37. package/src/commands/get-attestation.ts +58 -0
  38. package/src/commands/multi-attest.ts +75 -0
  39. package/src/commands/multi-revoke.ts +60 -0
  40. package/src/commands/multi-timestamp.ts +43 -0
  41. package/src/commands/offchain-attest.ts +78 -0
  42. package/src/commands/query-attestation.ts +31 -0
  43. package/src/commands/query-attestations.ts +57 -0
  44. package/src/commands/query-schema.ts +24 -0
  45. package/src/commands/query-schemas.ts +35 -0
  46. package/src/commands/revoke.ts +48 -0
  47. package/src/commands/schema-get.ts +30 -0
  48. package/src/commands/schema-register.ts +49 -0
  49. package/src/commands/set-key.ts +19 -0
  50. package/src/commands/timestamp.ts +35 -0
  51. package/src/config.ts +41 -0
  52. package/src/graphql.ts +136 -0
  53. package/src/index.ts +74 -0
  54. package/src/output.ts +50 -0
  55. package/src/stdin.ts +15 -0
  56. package/src/validation.ts +15 -0
  57. package/tsconfig.json +16 -0
  58. package/tsup.config.ts +21 -0
  59. package/vitest.config.ts +7 -0
@@ -0,0 +1,9 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(curl -s -X POST https://sepolia.easscan.org/graphql -H 'Content-Type: application/json' -d '{\"\"\"\"query\"\"\"\":\"\"\"\"{ schemata\\(take: 1\\) { id schema creator } }\"\"\"\"}')",
5
+ "Bash(curl -s -X POST https://sepolia.easscan.org/graphql -H 'Content-Type: application/json' -d '{\"\"\"\"query\"\"\"\":\"\"\"\"{ attestations\\(take: 1\\) { id attester recipient decodedDataJson schemaId } }\"\"\"\"}')",
6
+ "Bash(npm run:*)"
7
+ ]
8
+ }
9
+ }
package/README.md ADDED
@@ -0,0 +1,195 @@
1
+ # EAS CLI
2
+
3
+ Command-line interface for the [Ethereum Attestation Service](https://attest.org). Built on [EAS SDK v2](https://github.com/ethereum-attestation-service/eas-sdk-v2) and [ethers](https://docs.ethers.org).
4
+
5
+ All commands support `--json` for structured output and `--dry-run` for gas estimation without sending transactions.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install -g easctl
11
+ ```
12
+
13
+ Or run directly with npx:
14
+
15
+ ```bash
16
+ npx easctl --help
17
+ ```
18
+
19
+ ## Configuration
20
+
21
+ Store your private key for persistent use:
22
+
23
+ ```bash
24
+ easctl set-key 0xYourPrivateKeyHere
25
+ ```
26
+
27
+ This saves the key to `~/.eas-cli` (file permissions `0600`, owner-only) and displays your wallet address for confirmation.
28
+
29
+ To remove the stored key:
30
+
31
+ ```bash
32
+ easctl clear-key
33
+ ```
34
+
35
+ Alternatively, set the `EAS_PRIVATE_KEY` environment variable. When set, it takes priority over the stored key:
36
+
37
+ ```bash
38
+ export EAS_PRIVATE_KEY=0xYourPrivateKeyHere
39
+ ```
40
+
41
+ ## Commands
42
+
43
+ ### Attestations
44
+
45
+ ```bash
46
+ # Create an on-chain attestation
47
+ easctl attest \
48
+ --schema 0xSchemaUID \
49
+ --data '[{"name":"score","type":"uint256","value":"100"}]' \
50
+ --recipient 0xRecipientAddress \
51
+ --chain sepolia
52
+
53
+ # Create multiple attestations in one transaction
54
+ easctl multi-attest \
55
+ --input '[{"schema":"0xSchemaUID","recipient":"0xAddr","data":[{"name":"score","type":"uint256","value":"100"}]}]' \
56
+ --chain sepolia
57
+
58
+ # Create an off-chain (signed, not submitted) attestation
59
+ easctl offchain-attest \
60
+ --schema 0xSchemaUID \
61
+ --data '[{"name":"score","type":"uint256","value":"100"}]' \
62
+ --recipient 0xRecipientAddress \
63
+ --chain sepolia
64
+
65
+ # Revoke an attestation
66
+ easctl revoke --schema 0xSchemaUID --uid 0xAttestationUID --chain sepolia
67
+
68
+ # Revoke multiple attestations in one transaction
69
+ easctl multi-revoke \
70
+ --input '[{"schema":"0xSchemaUID","uid":"0xUID1"},{"schema":"0xSchemaUID","uid":"0xUID2"}]' \
71
+ --chain sepolia
72
+
73
+ # Get an attestation by UID (read-only, no key required)
74
+ easctl get-attestation --uid 0xAttestationUID --chain sepolia
75
+
76
+ # Auto-decode attestation data by fetching its schema from chain
77
+ easctl get-attestation --uid 0xAttestationUID --decode --chain sepolia
78
+
79
+ # Decode with an explicit schema string
80
+ easctl get-attestation --uid 0xAttestationUID --decode "uint256 score, string comment" --chain sepolia
81
+ ```
82
+
83
+ ### Schemas
84
+
85
+ ```bash
86
+ # Register a new schema
87
+ easctl schema-register --schema "uint256 score, string comment" --chain sepolia
88
+
89
+ # Get a schema by UID (read-only)
90
+ easctl schema-get --uid 0xSchemaUID --chain sepolia
91
+ ```
92
+
93
+ ### Timestamps
94
+
95
+ ```bash
96
+ # Timestamp a single data item on-chain
97
+ easctl timestamp --data 0xBytes32Data --chain sepolia
98
+
99
+ # Timestamp multiple data items in one transaction
100
+ easctl multi-timestamp --data '["0xBytes32Data1","0xBytes32Data2"]' --chain sepolia
101
+ ```
102
+
103
+ ### Queries
104
+
105
+ Query attestations and schemas from the EASScan indexer. Read-only, no private key required.
106
+
107
+ ```bash
108
+ # Query a single attestation
109
+ easctl query-attestation --uid 0xAttestationUID --chain sepolia
110
+
111
+ # Query a single schema
112
+ easctl query-schema --uid 0xSchemaUID --chain sepolia
113
+
114
+ # Query attestations by schema or attester, with pagination
115
+ easctl query-attestations --schema 0xSchemaUID --limit 20 --skip 40 --chain sepolia
116
+ easctl query-attestations --attester 0xAddress --chain sepolia
117
+
118
+ # Query schemas by creator
119
+ easctl query-schemas --creator 0xAddress --limit 20 --chain sepolia
120
+ ```
121
+
122
+ ### Utility
123
+
124
+ ```bash
125
+ # List supported chains
126
+ easctl chains
127
+ ```
128
+
129
+ ## Options
130
+
131
+ ### Global
132
+
133
+ | Option | Description |
134
+ |-----------|------------------------------------------|
135
+ | `--json` | Output results as JSON |
136
+ | `--help` | Display help for any command |
137
+
138
+ ### Per command
139
+
140
+ | Option | Description | Default |
141
+ |------------------|--------------------------------------------------|--------------|
142
+ | `-c, --chain` | Target chain | `ethereum` |
143
+ | `--rpc-url` | Custom RPC endpoint | Chain default|
144
+ | `--dry-run` | Estimate gas without sending (write commands) | - |
145
+
146
+ ## Supported Chains
147
+
148
+ Ethereum, Sepolia, Base, Base Sepolia, Optimism, Optimism Sepolia, Arbitrum, Arbitrum Sepolia, Polygon, Scroll, Linea, Celo.
149
+
150
+ ## JSON Output
151
+
152
+ All commands return structured JSON when `--json` is passed:
153
+
154
+ ```json
155
+ {
156
+ "success": true,
157
+ "data": {
158
+ "uid": "0x...",
159
+ "txHash": "0x...",
160
+ "attester": "0x...",
161
+ "chain": "sepolia"
162
+ }
163
+ }
164
+ ```
165
+
166
+ On error:
167
+
168
+ ```json
169
+ {
170
+ "success": false,
171
+ "error": "Error message here"
172
+ }
173
+ ```
174
+
175
+ ## Stdin Support
176
+
177
+ Commands that accept `--data` or `--input` can read from stdin by passing `-`:
178
+
179
+ ```bash
180
+ cat attestation-data.json | easctl attest --schema 0x... --data - --chain sepolia
181
+ cat revocations.json | easctl multi-revoke --input - --chain sepolia
182
+ ```
183
+
184
+ ## Development
185
+
186
+ ```bash
187
+ npm install
188
+ npm run build
189
+ npm run test
190
+ node dist/index.js --help
191
+ ```
192
+
193
+ ## License
194
+
195
+ MIT