Skip to main content

Hypercert SDK

Quickstart Guide

  1. Install the SDK using npm or yarn:
pnpm install @hypercerts-org/sdk

or

 pnpm add @hypercerts-org/sdk
  1. Import the SDK into your project:
import { HypercertClient } from "@hypercerts-org/sdk";
  1. Create a new instance of the HypercertClient class with your configuration options:
const client = new HypercertClient({
environment: "test",
walletClient, // optional, client will default to read-only mode if not provided
publicClient, // optional, can be infered from walletClient if present
});

Note If there's no walletClient provided the client will run in read-only mode

  1. Use the client object to interact with the Hypercert network.

For example, you can use the client.mintClaim method to create a new claim:

const hash = await client.mintHypercert({
metaData: { ... },
totalUnits: 1000n,
transferRestriction: TransferRestrictions.AllowAll,
});

This will validate the metadata, store it on IPFS, create a new hypercert on-chain and return a transaction receipt.

For more information on how to use the SDK, check out the developer documentation and the Graph playground.

That's it! With these simple steps, you can start using the Hypercert SDK in your own projects.

Config

HypercertClientConfig is a configuration object used when initializing a new instance of the HypercertClient. It allows you to customize the client by setting your own providers or deployments. At it's simplest, you only need to provide chain.id to initalize the client in readonly mode.

FieldTypeDescription
environment'test' | 'production'Defines the environment the client will connect with.
deploymentsObjectThe deployments of the contracts on various networks.
readOnlyBooleanBoolean to assert if the client is in read-only mode.
graphUrlStringThe URL of the graph endpoint.
publicClientObjectThe PublicClient is inherently read-only and is used for reading data from the blockchain.
walletClientObjectThe WalletClient is used for signing and sending transactions.

Read-only mode

The SDK client will be in read-only mode if any of the following conditions are true:

  • The client was initialized without a wallet client.
  • The client was initialized with a wallet client connected to a chain that is not supported in the environment.

Logging

The logger for the SDK uses the log level based on the value of the LOG_LEVEL environment variable. The log level determines which log messages are printed to the console. By default, the logger is configured to log messages with a level of info or higher to the console.

Modules

Storage

The storage module is an utility service for easy access to the hypercerts API. It's built based on the OpenAPI spec exposed by the hypercerts API.

 const client = new HypercertClient({
environment: "test",
walletClient, // optional, client will default to read-only mode if not provided
publicClient, // optional, can be infered from walletClient if present
});

const storage = client.storage;

const storageRequest = { metadata: {...}}
const storageResponse = await client.storage.storeMetadata(storageRequest);