You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resolve a SOL-DID with the following code snippet:
63
74
```ts
64
75
const didDoc =awaitservice.resolve();
65
76
console.log(JSON.stringify(didDoc, null, 2));
66
77
```
67
78
68
-
### Information about DID resolution
79
+
### DID resolution information
69
80
`did:sol` DIDs are resolved in the following way:
70
81
1.`Generative` DIDs are DIDs that have no persisted DID data account. (e.g. every valid Solana Account/Wallet is in this state).
71
82
This will return a generative DID document where only the public key of the Account is a valid Verification Method.
@@ -76,16 +87,16 @@ on-chain.
76
87
## Usage - `did:sol` Manipulation
77
88
The following are instructions that can be executed against a DID.
78
89
79
-
When manipulating a DID one generally needs three authoritative elements:
90
+
When manipulating a DID, three elements are generally required:
80
91
81
92
1. An `authority`, a (native) Verification Method with a `Capability Invocation` flag, that is allowed to manipulate the DID.
82
93
2. A `fee payer`, a Solana account that covers the cost of the transaction execution.
83
94
3. A `(rent) payer`, a Solana account that covers an (eventual) initialization or resize of the DID data account.
84
95
85
-
Generally, all these entities are required for successful DID manipulation. Except when increasing the DID account size,
86
-
then only a `rent payer` is needed. Often all these accounts are represented by the same account, but this is
87
-
not a requirement. For the example, this enables the implementation of a permissionless proxy that satisfies
88
-
`2` and `3` to submit an authority-signed instruction/transaction to chain.
96
+
Often, all of these entities are required for successful DID manipulation. However, when increasing the DID account size,
97
+
then only a `rent payer` is needed. In most cases, all three elements are represented by the same account, but this is
98
+
not a requirement. It is possible to implement a permissionless proxy that satisfies the fee payer and the rent payer to submit an authority-signed instruction/transaction to the chain. For example, a dApp might opt to pay fees to encourage user onboarding.
99
+
89
100
90
101
Generally, a manipulative DID operation has the following form:
91
102
@@ -138,7 +149,7 @@ Here's a breakdown of all exposed Builder functions:
138
149
9.`async instructions(): Promise<TransactionInstruction[]>`: Terminal method that creates and returns the instruction(s) (Eth signing will be applied if applicable).
139
150
140
151
### Changing of DID Operations
141
-
Generally, `DidSolService` allows to chain multiple operations after one another. For example
152
+
`DidSolService` allows chaining multiple operations one after another. For example:
@@ -157,12 +168,11 @@ Generally, `DidSolService` allows to chain multiple operations after one another
157
168
.withAutomaticAlloc(nonAuthoritySigner.publicKey)
158
169
.rpc();
159
170
```
160
-
This operation chains 1 removeService and 2 addService operations that are signed
171
+
This operation chains one(1) `removeService` and two(2) `addService` operations that are signed
161
172
by and `ethSigner` and optionally resizes the account.
162
173
163
174
### Init a DID Account
164
-
Generally, all DID operations can be performed with `withAutomaticAlloc(payer: PublicKey)`, which automatically creates a DID data account of the required size. However, the API still supports manually initializing a DID account of any size.
165
-
Allocating a sufficiently sized account upfront would allow not to use any payers for subsequent operations.
175
+
All DID operations can be performed with `withAutomaticAlloc(payer: PublicKey)`, which automatically creates a DID data account of the required size. However, the API still supports manually initializing a DID account of any size. Allocating an account upfront that is large enough for future modifications might prevent the need to use payers for subsequent operations. However, allocating a larger account increases the rent fees for that account.
@@ -171,15 +181,15 @@ The `initialize` operation does not support `withAutomaticAlloc` OR `withEthSig
171
181
argument will set the default DID authority as `payer` and size it to the minimal initial size required.
172
182
173
183
### Resize a DID Account
174
-
Generally, all DID operations can be performed with `withAutomaticAlloc(payer: PublicKey)`, which automatically creates or resizes a DID data account of the required size. However, the API still supports manually resizing a DID account of any size.
184
+
Generally, all DID operations can be performed with `withAutomaticAlloc(payer: PublicKey)`, which automatically creates or resizes a DID data account of the required size. However, the API also supports manually resizing a DID account of any size.
The `resize` operation does not support `withAutomaticAlloc`. Using `initialize` without an argument will set the default DID authority as `payer`.
189
+
The `resize` operation does not support `withAutomaticAlloc`. Using `initialize` without an argument will set the default DID authority as `payer`.
180
190
181
191
### Add a Verification Method
182
-
The operation will add a new Verification Method to the DID. The `keyData` can be a generically size`UInt8Array`, but logically it must match the methodType specified.
192
+
This operation adds a new Verification Method to the DID. The `keyData` can be a generically sized`UInt8Array`, but logically it must match the `methodType` specified.
183
193
184
194
```ts
185
195
awaitservice.addVerificationMethod({
@@ -193,8 +203,7 @@ The operation will add a new Verification Method to the DID. The `keyData` can b
193
203
```
194
204
195
205
### Remove a Verification Method
196
-
Removes a Verification Method with the given `fragment` from the DID. Note, that at least one valid Verification Method with
197
-
a `Capability Invocation` flag must remain to prevent a lockout.
206
+
This code removes a Verification Method with the given `fragment` from the DID. It is important to keep at least one valid Verification Method with a Capability Invocation flag to prevent a lockout.
198
207
199
208
```ts
200
209
awaitservice
@@ -211,8 +220,9 @@ that specific VM). `VerificationMethodFlags.OwnershipProof` is supported for the
211
220
-`EcdsaSecp256k1RecoveryMethod2020`
212
221
-`EcdsaSecp256k1VerificationKey2019`
213
222
223
+
In this example, the 'default" VM must match the `authority.publicKey`.
224
+
214
225
```ts
215
-
// Note in this example the 'default" VM must match authority.publicKey
@@ -301,11 +311,10 @@ which are not allowed to be specified within the bulk update.
301
311
.withAutomaticAlloc(authority.publicKey)
302
312
.rpc();
303
313
```
304
-
Note, that the `default` Verification Method can never be removed. Therefore not setting it within the update Method will cause all flags to be removed from it.
314
+
The `default` Verification Method can never be removed, therefore not setting it within the update Method will cause all flags to be removed from it.
305
315
306
316
### Update all properties of a DID with a DID Document
307
-
This operation allows for bulk updates of all changeable properties of a DID by passing an existing DidSolDocument.
308
-
Please note, that this is a more destructive operation and should be handled with care. Furthermore, by overwriting all Verification Methods it removes ANY existing `VerificationMethodFlags.OwnershipProof`,
317
+
This operation allows for bulk updates of all changeable properties of a DID by passing an existing DidSolDocument.This is a destructive operation and should be handled with care. Furthermore, by overwriting all Verification Methods it removes ANY existing `VerificationMethodFlags.OwnershipProof`,
309
318
which are not allowed to be specified within the bulk update.
310
319
311
320
```ts
@@ -357,16 +366,16 @@ which are not allowed to be specified within the bulk update.
357
366
```
358
367
359
368
### Close a DID Account
360
-
This transaction closes a DID account. With that, it implicitly reverts to its generative state.
369
+
This transaction closes a DID account, reverting it to its generative state.
The rent for the DID data account will be return to `rentDestination`.
375
+
The rent for the DID data account will be return to `rentDestination`. Closing a DID account requires using an `AuthoritySigner`.
367
376
368
377
### Migrate a persisted legacy DID to the new Program
369
-
Legacy DIDs are resolved fine with the current `did:sol` resolver, however, if you want to migrate a legacy DID (e.g. because you want to make use of all the new features), you can do so in the following way:
378
+
Legacy DIDs resolve without issues with the current `did:sol` resolver, however, if you want to migrate a legacy DID (e.g. to use the new features), you can do so with the following code:
370
379
371
380
In order to migrate a DID the following requirements need to be met:
372
381
- Persisted DID data account in the legacy program.
@@ -390,16 +399,13 @@ if (canMigrate) {
390
399
}
391
400
```
392
401
Note, that the migrate function works with a `nonAuthoritySigner`, e.g. that means ANYONE
393
-
can migrate any DID to the new program. But don't worry, since the migration keeps the state,
394
-
you can be happy if someone else does it for you.
395
-
396
-
In this example, however, `nonAuthoritySigner` is the `rent payer` for the new account.
402
+
can migrate any DID to the new program. However, the migration keeps the state, costs no more rent, and adds functionality, so no harm is done through the DID migration. Since legacy DIDs often automatically allocated a lot of space and new migrated DIDs are optimally space efficient, the migration to a new DID can actually save SOL.
403
+
In this example, however,
404
+
`nonAuthoritySigner` is the `rent payer` for the new account.
397
405
398
-
Furthermore, migrate takes an optional `legacyAuthority` argument. If specified, it closes
406
+
In this example, migrate takes an optional `legacyAuthority` argument. If specified, it closes
399
407
the legacy DID account automatically and recovers the rent to the `rent payer` of the new
400
-
account (`nonAuthoritySigner` in this example). Since legacy DIDs often automatically
401
-
allocated **a lot** of space and new migrated DIDs are optimally space efficient,
402
-
the migration to a new DID can actually make you `SOL` back.
408
+
account (`nonAuthoritySigner` in this example). This action can only be done by an AuthoritySigner, which protects the owner’s rent payer fees from being stolen.
0 commit comments