Retrieve an Immutable object by its name

How can I retrieve an immutable object by its name? As far as I understand, I can only retrieve Immutables that are in an Appendable - and through their handle ids, not through their actual names.

And how can I get an immutable’s name after creating it?

When you create the immutable data you are receiving the XOR-Name that is pointing to it. In order to access it, you’ll need to know that name. So you could store it somewhere.

Which API are you using? Rust-layer? FFI or Rest?

I’m using the Rest API.

This is how I’m creating a new immutable:

  1. Get writer handle: GET /immutable-data/writer (returns handleId)
  2. Write data: POST /immutable-data/:handleId (returns “OK”)
  3. Close writer: PUT /immutable-data/:handleId/:cipherOptsHandle (returns handleId)
  4. Drop data handle: DELETE /immutable-data/writer/:handleId (returns “OK”)

As you can see, no method returns the XOR-Name.

Hi @daniel,

yeah, the low level API is a bit … confusing… The idea is that you replace the handleID with a dataID (only that version of the API had that notion of things, we call it address now) through the data functions: https://api.safedev.org/low-level-api/data-id/get-data-id-handle.html

However, looking at that, I can’t find any way to get the data Id for iData :thinking: … Weird. Maybe @frabrunelle or @Krishna know better why and how you can retrieve it for that particular type…

2 Likes

HI @daniel, we didn’t expose the API and forced users to create using the immutable data writer. This was enforced to make sure the data is de-duped in the network. At the same time we were also debating on should we allow the direct APIs to create ImmutableData by passing the self-encryption. Was only in a discussion phase and was not exposed in the REST api.

1 Like

So does this mean that there is no way to store any sort of persistent reference to an object on the network with the Safe Launcher’s rest API?

You can serialize the data ID of the immutable data object using the data handle ID obtained when closing the immutable data writer. You can store the serialized data ID anywhere you want (e.g. in a structured data).

To retrieve the immutable data object, you can use the data ID handle obtained when deserializing the data ID you stored.

Let me know if that helps :slight_smile:

6 Likes