nChain Event
Back to All
V.1.3.1
V.1.3.1
  • nChain Event User Guide
  • Overview
    • Introduction
      • Target Audience
    • Features and Benefits
      • Independent Operations
      • Web3 Development
    • Core Concepts
    • Encoded and Unencoded Records
  • Using nChain Event
    • Initial Set-Up
  • Independent Records
    • Introduction
    • Functional Description
      • Write Record
      • Read Record
      • Verify Record
    • Use Cases
      • Lucky Number Tickets
      • Internet of Things (IoT) Data
      • Intellectual Property Rights (IPR) Evidence
      • Car Dealership
    • Tutorials
      • Data Integrity
    • API Workflow
      • Write Record
      • Get Location Status
      • Read Record
      • Verify Record
  • Linked Records
    • Introduction
      • Concept - Link Locations
    • Functional Description
      • Create Link Record
      • Read Link Record
      • Update Link Record
      • Delete Link Record
      • Verify Link Record
    • Use Cases
      • Luxury Handbag Provenance
    • Tutorials
      • Collection Integrity
      • Provenance Integrity
    • API Workflow
      • Create Link Record
      • Get Link Location Status
      • Read Link Record
      • Update Link Record
      • Delete Link Record
      • Verify Link Record
  • API Documentation
    • nChain Event API
  • Bitcoin SV Blockchain
    • Features and Benefits
    • Writing to Blockchain
    • Reading from Blockchain
    • Transaction Format
    • Troubleshooting
    • Glossary
Powered by GitBook
On this page
  • Update Encoded Link
  • Update Unencoded Link
  • Extract Location
  1. Linked Records
  2. API Workflow

Update Link Record

PreviousRead Link RecordNextDelete Link Record

This does not actually update a linked record on the blockchain. Instead, it creates a new linked record that prevents any further updates to the previous linked record, although it can still be queried for its status and content. Each linked record can only be updated once. To update the new linked record, a further new linked record must be created using the returned location of this linked record.

The record will be submitted to the blockchain asynchronously. You should use GET Location Status to find out whether the record has been confirmed before performing any other operations on the returned location.

Update Encoded Link

  1. The record owner selects any encoders (usually the same ones as previously used) and salt to use

  2. The record owner updates a link record via nChain Event

  3. nChain Event encodes the record as specified to produce a fingerprint

  4. The fingerprint is written to the blockchain, updating the previous link location

  5. The result is the new fingerprint and its new link location on the blockchain

  6. The record owner stores the new salt, fingerprint and location for later processing

  7. Any number of updates can be performed

Example code:

curl -X POST "$URL/api/v1/linkedrecords/$LOC/update?encode=SHA256(01-02T13.14.15)|Base64" \
     -H "x-api-key: $KEY" \
     -H "accept: text/plain" \
     -H "Content-Type: application/octet-stream" \
     --data-binary "hello world"
const response = await fetch('${url}/api/v1/linkedrecords/${loc}/update?
encode=SHA256(01-02T13.14.15)|Base64', {
  method: 'POST',
  headers: {
    'x-api-key': '${key}',
    'accept': 'text/plain',
    'Content-Type': 'application/octet-stream'
  },
  body: 'hello world'
});

Example cURL response:

{
  "txId": "7a22816fb63eff1....2377922ab58bdc2c2c13",
  "encoding" : [ 
    { "content-type": "…|Base64", "output" : "GDa1G3wEWsx4....y3RufuSXsARdiK8Wg=" }
  ]
  ...
}

The final "output" shows the record that was written to the blockchain.

Update Unencoded Link

  1. The record owner updates the previous link location with a new record via nChain Event

  2. The result is the new link Location of the new record on the blockchain

  3. The record owner stores the new link Location for later processing

  4. Any number of updates may be performed

  5. Ideally, the record owner should check the status of the new link location

Example code:

curl -X POST $URL/api/v1/linkedrecords/$LOC/update \
     -H "x-api-key: $KEY" \
     -H "accept: text/plain" \
     -H "Content-Type: application/octet-stream" \
     --data-binary "hello world"
const response = await fetch('${url}/api/v1/linkedrecords/${loc}/update, {
  method: 'POST',
  headers: {
    'x-api-key': '${key}',
    'accept': 'text/plain',
    'Content-Type': 'application/octet-stream'
  },
  body: 'hello world'
});

Example cURL response:

{
  "txId": "4674e3fc20a708dc....c32b37c76b724db48",
  ...
}

Extract Location

At least the location (shown as "txId") should be stored for subsequent operations:

LOC1=$LOC
LOC=4674e3fc20a708dc....c32b37c76b724db848
const data = await response.json();
const loc1 = data.txId;