Installation


The OCAP Client is a JavaScript library that connects your application to an OCAP blockchain. It works in both Node.js and browser environments. This guide will walk you through installing the client using a package manager.

Prerequisites#

Before you begin, ensure you have the following installed:

  • Node.js (which includes the npm package manager)
  • pnpm (optional, but recommended)

Install the Package#

You can install the @ocap/client package from the npm registry using either npm or pnpm.

Using npm#

Run the following command in your project's terminal:

npm

npm install @ocap/client

Using pnpm#

If you prefer using pnpm, run this command:

pnpm

pnpm install @ocap/client

This command will download the package and add it to your project's dependencies.

Verify Installation#

After the installation is complete, you can verify that the package is correctly installed by importing it into a JavaScript file. Create a file named test-client.js and add the following code:

Verify Installation

const OCapClient = require('@ocap/client');

if (OCapClient) {
  console.log('Successfully installed and imported @ocap/client!');
} else {
  console.error('Failed to import @ocap/client.');
}

Run the file from your terminal:

node test-client.js

You should see the success message printed to the console, confirming that the client is ready to use.

Next Steps#

Now that you have the client installed, you're ready to connect to the blockchain and start making requests. Continue to the next section to learn the basics.

  • Basic Usage: Learn how to initialize the client and make your first query.