# Blockchain Unique Identifiers

<figure><img src="/files/RcjXRjUrd5YRNuHH2k3i" alt="" width="563"><figcaption></figcaption></figure>

Use of [Universally and Globally Unique Identifiers](https://en.wikipedia.org/wiki/Universally_unique_identifier) (UUIDs/GUIDs) is a well known method for linking data across different organisations and systems. UIDs enhance data integrity and facilitate collaboration by providing a consistent reference point that remains unchanged over time, regardless of changes in ownership or system architecture.

nChain Event can create blockchain UIDs that can easily be converted into a [Version 4 (random)](https://en.wikipedia.org/wiki/Universally_unique_identifier) UUIDs/GUIDs for you.

A Version 4 (random) UUID/GUID is 128 bits containing 122 bits of randomness. We can create one from the location of a record written on the blockchain. The location comprises 256 random bits (driven by the entropy provided by the 256 bit ephemeral keys used in generating the signatures), so we will use the first 128 bits, and set the UID version and variant bits.

```typescript
  aRecord = "any payload you need, such as reference to the use of the UUID"

  aSalt = time.getNow() // use higher precision if needed

  aLocation = event.write(aRecord, aSalt) // register the record on the blockchain
  
  store(aRecord, aSalt, aLocation) // store for posterity

  aBUID = aLocation // the blockchain UID is the location of the record
  
  first128 = aBUID.substr(0, 16) // get the first 16 characters = 128 of 256 bits
  
  aUUID = uuid.create(first128, 4, 8) // set UUID version and variant bits
  
  // example: 8D8AC610-566D-4EF0-8C22-186B2A5ED793
```

The resultant UUID/GUID can be shared across your organisations and systems.

Or you can share the original location (the blockchain UID) instead, allowing anyone to check that the UUID/GUID is registered on the blockchain, check the reference in the payload, and generate the UUID/GUID themselves from the location using the same method.

## Benefits

* Transparency
* Global uniqueness
* Persistence
* Blockchain unique identifiers can have a reference payload
* Portable across any systems, departments, companies, consortia, institutions and countries


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.teranode.group/nchain-event/independent-records/tutorials/blockchain-unique-identifiers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
