@settlemint/sdk-eas 2.3.5-prfde1f9e5 → 2.3.6
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 +84 -221
- package/dist/browser/eas.d.ts +37 -1012
- package/dist/browser/eas.js +112 -885
- package/dist/browser/eas.js.map +1 -1
- package/dist/eas.cjs +110 -893
- package/dist/eas.cjs.map +1 -1
- package/dist/eas.d.cts +37 -1012
- package/dist/eas.d.ts +37 -1012
- package/dist/eas.js +112 -885
- package/dist/eas.js.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -27,133 +27,23 @@
|
|
|
27
27
|
## Table of Contents
|
|
28
28
|
|
|
29
29
|
- [About](#about)
|
|
30
|
-
- [Installation](#installation)
|
|
31
|
-
- [Quick Start](#quick-start)
|
|
32
|
-
- [ABI Configuration](#abi-configuration)
|
|
33
30
|
- [API Reference](#api-reference)
|
|
34
31
|
- [Functions](#functions)
|
|
35
32
|
- [createEASClient()](#createeasclient)
|
|
36
|
-
- [Classes](#classes)
|
|
37
|
-
- [EASPortalClient](#easportalclient)
|
|
38
33
|
- [Interfaces](#interfaces)
|
|
39
|
-
- [
|
|
34
|
+
- [RegisterSchemaOptions](#registerschemaoptions)
|
|
40
35
|
- [SchemaField](#schemafield)
|
|
41
36
|
- [Type Aliases](#type-aliases)
|
|
42
|
-
- [
|
|
37
|
+
- [ClientOptions](#clientoptions)
|
|
43
38
|
- [Variables](#variables)
|
|
39
|
+
- [ClientOptionsSchema](#clientoptionsschema)
|
|
44
40
|
- [EAS\_FIELD\_TYPES](#eas_field_types)
|
|
45
|
-
- [Error Handling](#error-handling)
|
|
46
41
|
- [Contributing](#contributing)
|
|
47
42
|
- [License](#license)
|
|
48
43
|
|
|
49
44
|
## About
|
|
50
45
|
|
|
51
|
-
The SettleMint EAS SDK provides a
|
|
52
|
-
|
|
53
|
-
**Key Features:**
|
|
54
|
-
- **Portal Integration**: Uses SettleMint's Portal GraphQL API for all contract interactions
|
|
55
|
-
- **Flexible ABI Support**: Hardcoded, custom, and predeployed ABI options with clear priority
|
|
56
|
-
- **Type Safety**: Full TypeScript support with proper type inference
|
|
57
|
-
- **Error Handling**: EAS-specific error codes and detailed error information
|
|
58
|
-
- **Real-time Monitoring**: Transaction status monitoring capabilities
|
|
59
|
-
|
|
60
|
-
## Installation
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
npm install @settlemint/sdk-eas
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Quick Start
|
|
67
|
-
|
|
68
|
-
```typescript
|
|
69
|
-
import { createEASClient } from "@settlemint/sdk-eas";
|
|
70
|
-
|
|
71
|
-
const client = createEASClient({
|
|
72
|
-
instance: "https://portal.settlemint.com",
|
|
73
|
-
accessToken: "your-access-token",
|
|
74
|
-
easContractAddress: "0x...", // Your EAS contract address
|
|
75
|
-
schemaRegistryContractAddress: "0x...", // Your Schema Registry address
|
|
76
|
-
// abiSource defaults to { type: "hardcoded" } - uses standard EAS ABIs
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// Register a schema
|
|
80
|
-
const result = await client.registerSchema({
|
|
81
|
-
schema: "address user, uint256 score",
|
|
82
|
-
resolver: "0x0000000000000000000000000000000000000000",
|
|
83
|
-
revocable: true,
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
console.log("Transaction Hash:", result.hash);
|
|
87
|
-
|
|
88
|
-
// Create an attestation
|
|
89
|
-
const attestation = await client.attest({
|
|
90
|
-
schema: "0x...", // Schema UID
|
|
91
|
-
data: {
|
|
92
|
-
recipient: "0x...",
|
|
93
|
-
expirationTime: 0n,
|
|
94
|
-
revocable: true,
|
|
95
|
-
refUID: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
96
|
-
data: "0x...", // Encoded attestation data
|
|
97
|
-
value: 0n,
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// Get an attestation
|
|
102
|
-
const attestationData = await client.getAttestation("0x...");
|
|
103
|
-
console.log("Attestation:", attestationData);
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
## ABI Configuration
|
|
107
|
-
|
|
108
|
-
The EAS SDK supports three ABI sources with the following priority:
|
|
109
|
-
|
|
110
|
-
### 1. Hardcoded ABIs (Default)
|
|
111
|
-
Uses standard EAS ABIs built into the SDK:
|
|
112
|
-
|
|
113
|
-
```typescript
|
|
114
|
-
const client = createEASClient({
|
|
115
|
-
instance: "https://portal.settlemint.com",
|
|
116
|
-
accessToken: "your-token",
|
|
117
|
-
easContractAddress: "0x...",
|
|
118
|
-
schemaRegistryContractAddress: "0x...",
|
|
119
|
-
// abiSource defaults to { type: "hardcoded" }
|
|
120
|
-
});
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### 2. Custom ABIs (User Override)
|
|
124
|
-
Override with your own ABIs:
|
|
125
|
-
|
|
126
|
-
```typescript
|
|
127
|
-
import { EAS_ABI, SCHEMA_REGISTRY_ABI } from "@settlemint/sdk-eas";
|
|
128
|
-
|
|
129
|
-
const client = createEASClient({
|
|
130
|
-
instance: "https://portal.settlemint.com",
|
|
131
|
-
accessToken: "your-token",
|
|
132
|
-
easContractAddress: "0x...",
|
|
133
|
-
schemaRegistryContractAddress: "0x...",
|
|
134
|
-
abiSource: {
|
|
135
|
-
type: "custom",
|
|
136
|
-
easAbi: EAS_ABI, // or your custom ABI
|
|
137
|
-
schemaRegistryAbi: SCHEMA_REGISTRY_ABI, // or your custom ABI
|
|
138
|
-
},
|
|
139
|
-
});
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### 3. Predeployed ABIs (Portal's ABIs)
|
|
143
|
-
Use Portal's predeployed ABIs:
|
|
144
|
-
|
|
145
|
-
```typescript
|
|
146
|
-
const client = createEASClient({
|
|
147
|
-
instance: "https://portal.settlemint.com",
|
|
148
|
-
accessToken: "your-token",
|
|
149
|
-
easContractAddress: "0x...",
|
|
150
|
-
schemaRegistryContractAddress: "0x...",
|
|
151
|
-
abiSource: {
|
|
152
|
-
type: "predeployed",
|
|
153
|
-
abiNames: ["eas"], // Optional, defaults to ["eas"]
|
|
154
|
-
},
|
|
155
|
-
});
|
|
156
|
-
```
|
|
46
|
+
The SettleMint EAS SDK provides a lightweight wrapper for the Ethereum Attestation Service (EAS), enabling developers to easily create, manage, and verify attestations within their applications. It simplifies the process of working with EAS by handling contract interactions, schema management, and The Graph integration, while ensuring proper integration with the SettleMint platform. This allows developers to quickly implement document verification, identity attestation, and other EAS-based features without manual setup.
|
|
157
47
|
|
|
158
48
|
## API Reference
|
|
159
49
|
|
|
@@ -161,21 +51,38 @@ const client = createEASClient({
|
|
|
161
51
|
|
|
162
52
|
#### createEASClient()
|
|
163
53
|
|
|
164
|
-
> **createEASClient**(`options`):
|
|
54
|
+
> **createEASClient**(`options`): `object`
|
|
165
55
|
|
|
166
|
-
|
|
56
|
+
Defined in: [sdk/eas/src/eas.ts:36](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/eas.ts#L36)
|
|
57
|
+
|
|
58
|
+
Creates an EAS client for interacting with the Ethereum Attestation Service.
|
|
167
59
|
|
|
168
60
|
##### Parameters
|
|
169
61
|
|
|
170
62
|
| Parameter | Type | Description |
|
|
171
63
|
| ------ | ------ | ------ |
|
|
172
|
-
| `options` |
|
|
64
|
+
| `options` | \{ `accessToken`: `string`; `attestationAddress`: `string`; `chainId`: `string`; `chainName`: `string`; `rpcUrl`: `string`; `schemaRegistryAddress`: `string`; \} | Configuration options for the client |
|
|
65
|
+
| `options.accessToken` | `string` | Access token for the RPC provider (must start with 'sm_aat_' or 'sm_pat_') |
|
|
66
|
+
| `options.attestationAddress` | `string` | The address of the EAS Attestation contract |
|
|
67
|
+
| `options.chainId` | `string` | The chain ID to connect to |
|
|
68
|
+
| `options.chainName` | `string` | The name of the chain to connect to |
|
|
69
|
+
| `options.rpcUrl` | `string` | The RPC URL to connect to (must be a valid URL) |
|
|
70
|
+
| `options.schemaRegistryAddress` | `string` | The address of the EAS Schema Registry contract |
|
|
173
71
|
|
|
174
72
|
##### Returns
|
|
175
73
|
|
|
176
|
-
|
|
74
|
+
`object`
|
|
75
|
+
|
|
76
|
+
An object containing the EAS client instance
|
|
77
|
+
|
|
78
|
+
| Name | Type | Defined in |
|
|
79
|
+
| ------ | ------ | ------ |
|
|
80
|
+
| `getSchema()` | (`uid`) => `Promise`\<`string`\> | [sdk/eas/src/eas.ts:96](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/eas.ts#L96) |
|
|
81
|
+
| `registerSchema()` | (`options`) => `Promise`\<`string`\> | [sdk/eas/src/eas.ts:95](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/eas.ts#L95) |
|
|
177
82
|
|
|
178
|
-
|
|
83
|
+
##### Throws
|
|
84
|
+
|
|
85
|
+
Will throw an error if the options fail validation
|
|
179
86
|
|
|
180
87
|
##### Example
|
|
181
88
|
|
|
@@ -183,137 +90,93 @@ An EAS Portal client instance
|
|
|
183
90
|
import { createEASClient } from '@settlemint/sdk-eas';
|
|
184
91
|
|
|
185
92
|
const client = createEASClient({
|
|
186
|
-
|
|
93
|
+
schemaRegistryAddress: "0x1234567890123456789012345678901234567890",
|
|
94
|
+
attestationAddress: "0x1234567890123456789012345678901234567890",
|
|
187
95
|
accessToken: "your-access-token",
|
|
188
|
-
|
|
189
|
-
|
|
96
|
+
chainId: "1",
|
|
97
|
+
chainName: "Ethereum",
|
|
98
|
+
rpcUrl: "http://localhost:8545"
|
|
190
99
|
});
|
|
191
100
|
```
|
|
192
101
|
|
|
193
|
-
### Classes
|
|
194
|
-
|
|
195
|
-
#### EASPortalClient
|
|
196
|
-
|
|
197
|
-
The main client class for interacting with EAS contracts via Portal.
|
|
198
|
-
|
|
199
|
-
##### Methods
|
|
200
|
-
|
|
201
|
-
- `registerSchema(request: SchemaRequest): Promise<TransactionResult>` - Register a new schema
|
|
202
|
-
- `attest(request: AttestationRequest): Promise<TransactionResult>` - Create an attestation
|
|
203
|
-
- `multiAttest(requests: AttestationRequest[]): Promise<TransactionResult>` - Create multiple attestations
|
|
204
|
-
- `revoke(uid: Hex, value?: bigint): Promise<TransactionResult>` - Revoke an attestation
|
|
205
|
-
- `getAttestation(uid: Hex): Promise<AttestationData>` - Retrieve attestation data
|
|
206
|
-
- `getSchema(uid: Hex): Promise<SchemaData>` - Retrieve schema data
|
|
207
|
-
- `isValidAttestation(uid: Hex): Promise<boolean>` - Check if attestation is valid
|
|
208
|
-
- `getTimestamp(): Promise<bigint>` - Get current contract timestamp
|
|
209
|
-
- `getPortalClient(): unknown` - Access underlying Portal client
|
|
210
|
-
- `getOptions(): PortalClientOptions` - Get client configuration
|
|
211
|
-
- `getAbis(): { easAbi: Abi; schemaRegistryAbi: Abi }` - Get current ABIs
|
|
212
|
-
|
|
213
102
|
### Interfaces
|
|
214
103
|
|
|
215
|
-
####
|
|
104
|
+
#### RegisterSchemaOptions
|
|
105
|
+
|
|
106
|
+
Defined in: [sdk/eas/src/types.ts:34](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L34)
|
|
216
107
|
|
|
217
|
-
|
|
108
|
+
Options for registering a new schema in the EAS Schema Registry.
|
|
218
109
|
|
|
219
110
|
##### Properties
|
|
220
111
|
|
|
221
|
-
| Property | Type | Description |
|
|
222
|
-
| ------ | ------ | ------ |
|
|
223
|
-
| `
|
|
224
|
-
| `
|
|
225
|
-
| `
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
| `wsUrl?` | `string` | Optional WebSocket URL for real-time monitoring |
|
|
229
|
-
| `timeout?` | `number` | Request timeout in milliseconds (default: 30000) |
|
|
230
|
-
| `debug?` | `boolean` | Enable debug logging (default: false) |
|
|
231
|
-
| `cache?` | `string` | Cache configuration for GraphQL requests |
|
|
112
|
+
| Property | Type | Description | Defined in |
|
|
113
|
+
| ------ | ------ | ------ | ------ |
|
|
114
|
+
| <a id="fields"></a> `fields` | [`SchemaField`](#schemafield)[] | Array of fields that make up the schema | [sdk/eas/src/types.ts:36](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L36) |
|
|
115
|
+
| <a id="resolveraddress"></a> `resolverAddress` | `string` | Address of the resolver contract that will handle attestations | [sdk/eas/src/types.ts:38](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L38) |
|
|
116
|
+
| <a id="revocable"></a> `revocable` | `boolean` | Whether attestations using this schema can be revoked | [sdk/eas/src/types.ts:40](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L40) |
|
|
117
|
+
|
|
118
|
+
***
|
|
232
119
|
|
|
233
120
|
#### SchemaField
|
|
234
121
|
|
|
122
|
+
Defined in: [sdk/eas/src/types.ts:22](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L22)
|
|
123
|
+
|
|
235
124
|
Represents a single field in an EAS schema.
|
|
236
125
|
|
|
237
126
|
##### Properties
|
|
238
127
|
|
|
239
|
-
| Property | Type | Description |
|
|
240
|
-
| ------ | ------ | ------ |
|
|
241
|
-
| `
|
|
242
|
-
| `
|
|
243
|
-
| `
|
|
128
|
+
| Property | Type | Description | Defined in |
|
|
129
|
+
| ------ | ------ | ------ | ------ |
|
|
130
|
+
| <a id="description"></a> `description?` | `string` | Optional description of the field's purpose | [sdk/eas/src/types.ts:28](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L28) |
|
|
131
|
+
| <a id="name"></a> `name` | `string` | The name of the field | [sdk/eas/src/types.ts:24](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L24) |
|
|
132
|
+
| <a id="type"></a> `type` | `"string"` \| `"address"` \| `"bool"` \| `"bytes"` \| `"bytes32"` \| `"int8"` \| `"int256"` \| `"uint8"` \| `"uint256"` | The Solidity type of the field | [sdk/eas/src/types.ts:26](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L26) |
|
|
244
133
|
|
|
245
134
|
### Type Aliases
|
|
246
135
|
|
|
247
|
-
####
|
|
136
|
+
#### ClientOptions
|
|
248
137
|
|
|
249
|
-
|
|
138
|
+
> **ClientOptions** = `z.infer`\<*typeof* [`ClientOptionsSchema`](#clientoptionsschema)\>
|
|
250
139
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
| { type: "predeployed"; abiNames?: string[] };
|
|
256
|
-
```
|
|
140
|
+
Defined in: [sdk/eas/src/client-options.schema.ts:28](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/client-options.schema.ts#L28)
|
|
141
|
+
|
|
142
|
+
Configuration options for creating an EAS client.
|
|
143
|
+
Combines EAS-specific options with base Viem client options.
|
|
257
144
|
|
|
258
145
|
### Variables
|
|
259
146
|
|
|
147
|
+
#### ClientOptionsSchema
|
|
148
|
+
|
|
149
|
+
> `const` **ClientOptionsSchema**: `ZodObject`\<\{ `accessToken`: `ZodString`; `attestationAddress`: `ZodString`; `chainId`: `ZodString`; `chainName`: `ZodString`; `rpcUrl`: `ZodString`; `schemaRegistryAddress`: `ZodString`; \}, `$strip`\>
|
|
150
|
+
|
|
151
|
+
Defined in: [sdk/eas/src/client-options.schema.ts:9](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/client-options.schema.ts#L9)
|
|
152
|
+
|
|
153
|
+
Schema for validating EAS client configuration options.
|
|
154
|
+
Extends the base Viem client options with EAS-specific requirements.
|
|
155
|
+
|
|
156
|
+
***
|
|
157
|
+
|
|
260
158
|
#### EAS\_FIELD\_TYPES
|
|
261
159
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
```typescript
|
|
265
|
-
const EAS_FIELD_TYPES = {
|
|
266
|
-
string: "string",
|
|
267
|
-
address: "address",
|
|
268
|
-
bool: "bool",
|
|
269
|
-
bytes: "bytes",
|
|
270
|
-
bytes32: "bytes32",
|
|
271
|
-
uint256: "uint256",
|
|
272
|
-
int256: "int256",
|
|
273
|
-
uint8: "uint8",
|
|
274
|
-
int8: "int8",
|
|
275
|
-
} as const;
|
|
276
|
-
```
|
|
160
|
+
> `const` **EAS\_FIELD\_TYPES**: `object`
|
|
277
161
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
try {
|
|
286
|
-
await client.getAttestation("invalid-uid");
|
|
287
|
-
} catch (error) {
|
|
288
|
-
if (error instanceof EASPortalError) {
|
|
289
|
-
switch (error.code) {
|
|
290
|
-
case EASErrorCode.ATTESTATION_NOT_FOUND:
|
|
291
|
-
console.log("Attestation not found");
|
|
292
|
-
break;
|
|
293
|
-
case EASErrorCode.TRANSACTION_FAILED:
|
|
294
|
-
console.log("Transaction failed");
|
|
295
|
-
break;
|
|
296
|
-
case EASErrorCode.SCHEMA_NOT_FOUND:
|
|
297
|
-
console.log("Schema not found");
|
|
298
|
-
break;
|
|
299
|
-
// ... other error codes
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
```
|
|
162
|
+
Defined in: [sdk/eas/src/types.ts:5](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L5)
|
|
163
|
+
|
|
164
|
+
Supported field types for EAS schema fields.
|
|
165
|
+
Maps to the Solidity types that can be used in EAS schemas.
|
|
166
|
+
|
|
167
|
+
##### Type declaration
|
|
304
168
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
- `PORTAL_ERROR` - Portal-specific error
|
|
169
|
+
| Name | Type | Default value | Defined in |
|
|
170
|
+
| ------ | ------ | ------ | ------ |
|
|
171
|
+
| <a id="address"></a> `address` | `"address"` | `"address"` | [sdk/eas/src/types.ts:7](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L7) |
|
|
172
|
+
| <a id="bool"></a> `bool` | `"bool"` | `"bool"` | [sdk/eas/src/types.ts:8](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L8) |
|
|
173
|
+
| <a id="bytes"></a> `bytes` | `"bytes"` | `"bytes"` | [sdk/eas/src/types.ts:9](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L9) |
|
|
174
|
+
| <a id="bytes32"></a> `bytes32` | `"bytes32"` | `"bytes32"` | [sdk/eas/src/types.ts:10](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L10) |
|
|
175
|
+
| <a id="int256"></a> `int256` | `"int256"` | `"int256"` | [sdk/eas/src/types.ts:12](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L12) |
|
|
176
|
+
| <a id="int8"></a> `int8` | `"int8"` | `"int8"` | [sdk/eas/src/types.ts:14](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L14) |
|
|
177
|
+
| <a id="string"></a> `string` | `"string"` | `"string"` | [sdk/eas/src/types.ts:6](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L6) |
|
|
178
|
+
| <a id="uint256"></a> `uint256` | `"uint256"` | `"uint256"` | [sdk/eas/src/types.ts:11](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L11) |
|
|
179
|
+
| <a id="uint8"></a> `uint8` | `"uint8"` | `"uint8"` | [sdk/eas/src/types.ts:13](https://github.com/settlemint/sdk/blob/v2.3.6/sdk/eas/src/types.ts#L13) |
|
|
317
180
|
|
|
318
181
|
## Contributing
|
|
319
182
|
|