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
  • Create Encoded Link
  • Create Unencoded Link
  • Extract Location
  1. Linked Records
  2. API Workflow

Create Link Record

PreviousAPI WorkflowNextGet Link Location Status

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.

Create Encoded Link

  1. The record owner selects any encoders and salt to use

  2. The record owner creates an encoded link record via nChain Event

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

  4. The linked fingerprint is written to the blockchain

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

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

Example code:

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

Example cURL response:

{
  "txId": "4f170a122b82783d....43d2b5d99d3ed190d0b",
  "encoding" : [ 
    { "content-type": "…|Base64", "output" : "ytfc5c5wv0V7hOo....G1ucRFzSIe6rw=" }
  ]
  ...
}

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

Create Unencoded Link

  1. The record owner creates a record via nChain Event

  2. The result is the link location of the record on the blockchain

  3. The record owner stores the link location for later processing

  4. Ideally, the record owner should check the link location status

Example code:

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

Example cURL response:

{
  "txId": "47175b2ee3345942….d58cd286198e1bc97",
  ...
}

Extract Location

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

LOC=47175b2ee3345942....d58cd286198e1bcf97
const data = await response.json();
const loc = data.txId;