ion-tools
ion-tools copied to clipboard
Retrieve a DID object using the DID URI and make an update operation
Hello. I am trying to create a DID object in my local ION node, publish it and then make an update, to see if the new DID resolved returns the data I expect. I noticed two things:
- If I lose the DID object of the published DID, how can I retrieve it with its ION-tools functions? --- I solved it using ion-sdk, but I think it could be useful anyway ---
- After making an update, waiting for it to be published successfully, if I fetch the DID, I can't find any new data.
I made an example of my code here
What am I missing? The update transaction and operation are committed in mongoDb database and bitcoin node, but the resolved DID returns the 'first creation' did data.
+1 this would be nice - for some reason updating a ION DID is much more complicated once you lose the initial object.
@Ichigo85 @marek5050 README updated with complete working example of creating an updating an ION DID.
I also created an example repo that has detailed versions of create and update operations: https://github.com/frankhinek/did-ion-examples
Let me know if this resolves the open questions. Thanks.
Hi @Ichigo85, I just had a look at your example code (btw, thanks for sharing the code; this made it really easy to understand your problem).
In ION, there are different key pairs involved. On the one hand side, you have operation keys. They are used to authenticate you as the DID owner towards the ION network (i.e., are you allowed to update the DID document). When using the ion-tools library, you will basically never deal with them directly. Then there are keys that you want to put into your DID document, e.g. because you want to sign messages with them. These two types of keys are clearly separated in ION.
They key pair you generated with ION.generateKeyPair()
and saved to file was of the latter type (you put it into the DID document). Therefore you cannot use it to update your DID document later. The keys for updating your DID are implicitly generated by ion-tools when calling new ION.DID()
. You would need these operation keys to modify your DID document later. For this, you need to use getAllOperations()
to export the operation keys. The recent changes from @frankhinek nicely show this.
Hope I could help you and others to understand the problem. Feel free to close the issue if it's resolved
Hello @nikolockenvitz and @frankhinek ! Thank you very much for your useful explanation and for the updated example. Closing the issue now :)