Getting started overview

Chainpoint provides a method to create a tamper-proof record of any data, anchoring it to the Bitcoin blockchain. This proof of existence allows for later cryptographic verification that the data existed at a particular point in time. The process typically involves hashing your data, submitting the hash to the Chainpoint API, and receiving a Chainpoint proof. This guide outlines the steps to set up your Chainpoint account, obtain necessary credentials, and execute your first data timestamping request.

Quick-reference steps

The following table provides an overview of the initial steps to integrate with Chainpoint:

Step What to do Where
1. Create Account Register for a Chainpoint Developer account. Chainpoint Developer Portal
2. Get API Keys Locate and copy your API Key from your dashboard. Chainpoint Developer Dashboard
3. Install Client (Optional) Install the Chainpoint Client for Node.js if using a client library. Chainpoint Client Installation Guide
4. Hash Data Generate a SHA256 hash of the data you wish to timestamp. Local development environment or Web Crypto API
5. Make Request Submit your data hash to the Chainpoint API using your API Key. Your application code or cURL
6. Verify Proof Retrieve and verify the Chainpoint proof. Chainpoint API or Client Library

Create an account and get keys

To begin using Chainpoint, you must first create a developer account. This account grants you access to the Chainpoint API and your unique API keys, which authenticate your requests.

Account creation

  1. Navigate to the Chainpoint Developer Portal.
  2. Click on the "Sign Up" or "Get Started" option.
  3. Provide the required information, typically including an email address and a strong password.
  4. Complete any email verification steps as prompted to activate your account.

Upon successful registration, you will gain access to your developer dashboard.

API key retrieval

Your API key is a unique identifier that authenticates your requests to the Chainpoint API. Keep this key confidential to prevent unauthorized access to your account and usage.

  1. Log in to your Chainpoint Developer Dashboard.
  2. Look for a section labeled "API Keys", "Credentials", or "Settings".
  3. Your API key will be displayed. Copy this key and store it securely. You will include this key in the headers or body of your API requests.

Chainpoint offers a free tier for initial development, allowing up to 100 anchors per month without charge. For higher volumes, tiered pricing starts at $5 per month for 1,000 anchors.

Your first request

This section outlines how to make your first request to the Chainpoint API to timestamp data. The core process involves hashing your data and then submitting that hash to the API. We will demonstrate using both cURL for a direct API call and the Node.js Chainpoint Client library.

Step 1: Hash your data

Before sending data to Chainpoint, you must hash it. Chainpoint uses SHA256 hashes. This ensures that the original data remains private while its integrity can still be proven. For demonstration purposes, we will use a simple string.

Using Node.js to generate a SHA256 hash:

const crypto = require('crypto');

const dataToHash = 'This is the data I want to timestamp securely.';
const hash = crypto.createHash('sha256').update(dataToHash).digest('hex');

console.log('SHA256 Hash:', hash);
// Example output: SHA256 Hash: 9da4339904999f7d0c7d41349f76a59132207b14d23d8c199e4d0e59a8523c94

Alternatively, you can use online tools or command-line utilities (e.g., shasum -a 256 on macOS/Linux) to generate the hash for testing.

Step 2: Submit the hash to Chainpoint

Once you have your SHA256 hash, you can submit it to the Chainpoint API. Replace YOUR_API_KEY with the key you obtained from your dashboard.

Using cURL (direct API call):

curl -X POST \n  https://api.chainpoint.org/hashes \n  -H 'Content-Type: application/json' \n  -H 'Authorization: Bearer YOUR_API_KEY' \n  -d '[{"hash_id": "9da4339904999f7d0c7d41349f76a59132207b14d23d8c199e4d0e59a8523c94", "hash": "9da4339904999f7d0c7d41349f76a59132207b14d23d8c199e4d0e59a8523c94"}]'

The hash_id and hash fields should contain the same SHA256 hash. The API will return a unique Chainpoint ID for your submission.

A successful response will look similar to this:

[
  {
    "hash_id": "9da4339904999f7d0c7d41349f76a59132207b14d23d8c199e4d0e59a8523c94",
    "chainpoint_id": "d7d8c199e4d0e59a8523c949da4339904999f7d0c7d41349f76a59132207b14"
  }
]

Store the chainpoint_id. This identifier is crucial for retrieving your Chainpoint proof later.

Using the Chainpoint Client for Node.js:

First, install the client library:

npm install chainpoint-client

Then, use the client to submit your hash:

const chainpoint = require('chainpoint-client');

async function submitHash() {
  const dataToHash = 'This is the data I want to timestamp securely.';
  const hash = require('crypto').createHash('sha256').update(dataToHash).digest('hex');

  try {
    const hashes = [{ hash_id: hash, hash: hash }];
    const options = { serverUrl: 'https://api.chainpoint.org', api_key: 'YOUR_API_KEY' };
    const response = await chainpoint.submitHashes(hashes, options);
    console.log('Submitted Hashes:', response);
    // response will contain chainpoint_id for each hash
  } catch (error) {
    console.error('Error submitting hash:', error.message);
  }
}

submitHash();

The client library simplifies the API interaction, handling details like request formatting and authentication.

Step 3: Retrieve and verify the Chainpoint proof

After submitting your hash, Chainpoint processes it and incorporates it into the Bitcoin blockchain. This process takes some time, typically a few hours, depending on network congestion. You can retrieve the proof using the chainpoint_id obtained in the previous step.

Using cURL to retrieve a proof:

curl -X GET \n  https://api.chainpoint.org/proofs/d7d8c199e4d0e59a8523c949da4339904999f7d0c7d41349f76a59132207b14 \n  -H 'Authorization: Bearer YOUR_API_KEY'

Using the Chainpoint Client for Node.js to retrieve and verify:

const chainpoint = require('chainpoint-client');

async function retrieveAndVerifyProof(chainpointId) {
  try {
    const options = { serverUrl: 'https://api.chainpoint.org', api_key: 'YOUR_API_KEY' };
    const proofs = await chainpoint.getProofs([chainpointId], options);
    console.log('Retrieved proofs:', proofs);

    // Verify the proof
    const hashesToVerify = [{ hash: '9da4339904999f7d0c7d41349f76a59132207b14d23d8c199e4d0e59a8523c94', proof: proofs[0] }];
    const verificationResults = await chainpoint.verifyProofs(hashesToVerify);
    console.log('Verification results:', verificationResults);
    // Each result will indicate 'verified: true' or 'verified: false'

  } catch (error) {
    console.error('Error retrieving or verifying proof:', error.message);
  }
}

// Replace with your actual chainpointId from the submission step
retrieveAndVerifyProof('d7d8c199e4d0e59a8523c949da4339904999f7d0c7d41349f76a59132207b14');

The verification process confirms that the retrieved proof cryptographically links your original hash to the Bitcoin blockchain, thereby confirming the data's integrity and existence at the timestamped block.

Common next steps

After successfully making your first Chainpoint request, consider these next steps for further integration and development:

  • Automate Proof Retrieval: Implement a mechanism to periodically check for and retrieve proofs once they are anchored to the blockchain. This often involves storing the chainpoint_id and querying the API after a suitable delay.
  • Error Handling: Implement robust error handling in your application to manage API rate limits, invalid requests, and network issues. Consult the Chainpoint API reference for specific error codes and messages.
  • Integrate with Your Application: Incorporate Chainpoint into your existing workflows for document management, digital asset protection, or data logging. For example, you might timestamp legal documents, academic certificates, or IoT sensor data.
  • Explore Advanced Features: Review the Chainpoint developer documentation for details on batching multiple hashes in a single request, which can reduce transaction costs and improve efficiency for high-volume applications.
  • Security Best Practices: Ensure your API keys are stored securely and never exposed client-side. Utilize environment variables or secure credential management systems. For more information on API security, refer to the Microsoft Azure API Gateway documentation on securing APIs.
  • Monitor Usage: Keep track of your API usage through your Chainpoint developer dashboard to stay within your plan limits or to anticipate when an upgrade might be necessary.

Troubleshooting the first call

Encountering issues during your first API call is common. Here are some troubleshooting tips:

  • Invalid API Key: Double-check that you have copied your API key correctly and included it in the Authorization: Bearer YOUR_API_KEY header. An incorrect key will typically result in a 401 Unauthorized error.
  • Incorrect Request Format: Ensure your request body is valid JSON and matches the expected structure as described in the Chainpoint API documentation. Missing or malformed fields can lead to 400 Bad Request errors.
  • Content-Type Header: Verify that the Content-Type: application/json header is present in your POST requests.
  • Hash Format: Confirm that the hash you are submitting is a valid SHA256 hexadecimal string. Any other format will be rejected.
  • Network Issues: Check your internet connection and ensure that there are no firewall rules blocking outgoing requests to api.chainpoint.org.
  • Rate Limits: If you are making many requests in a short period, you might hit API rate limits. The Chainpoint API will typically return a 429 Too Many Requests error. Implement retries with exponential backoff if this occurs.
  • Server Status: Occasionally, API services can experience downtime. Check the official Chainpoint status page (if available) or their social channels for any service announcements.
  • Client Library Errors: If using the Node.js client, ensure it's installed correctly (npm install chainpoint-client) and that you are using the correct function calls as per the client library documentation.
  • Consult Documentation: The Chainpoint Developer Documentation is the primary resource for detailed error codes and usage examples.