npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hypercerts-org/sdk

v2.0.0-alpha.5

Published

SDK for hypercerts protocol

Downloads

759

Readme

Hypercert SDK

Quickstart Guide

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

or

 yarn 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({
  chain: { id: 11155111 }, // required
});

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 tx = await client.mintClaim(metaData, totalUnits, transferRestriction, overrides);

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

You can also use the client to query the subgraph and retrieve which claims an address owns:

const claims = await client.indexer.fractionsByOwner(owner);

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.

| Field | Type | Description | | --------------------------- | --------------------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------- | | chain | Object | Partial configuration for the blockchain network. | | contractAddress | String | The address of the deployed contract. | | graphName | String | The name of the subgraph. | | easContractAddress | String | The address of the EAS contract. | | publicClient | Object | The PublicClient is inherently read-only and is used for reading data from the blockchain. | | walletClient | Object | The WalletClient is used for signing and sending transactions. | | unsafeForceOverrideConfig | Boolean | Boolean to force the use of overridden values. | | readOnly | Boolean | Boolean to assert if the client is in read-only mode. | | readOnlyReason | String | Reason for read-only mode. This is optional and can be used for logging or debugging purposes. | | indexerEnvironment | 'test' \| 'production' \| 'all' | Determines which graphs should be read out when querying | The environment of the indexer. |

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 walletprovider.
  • The contract address is not set.
  • The storage layer is in read-only mode.

If any of these conditions are true, the readonly property of the HypercertClient instance will be set to true, and a warning message will be logged indicating that the client is in read-only mode.

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.

Client modules

The HypercertClient provides a high-level interface for interacting with the Hypercert ecosystem. The HypercertClient has three getter methods: storage, indexer, and contract. These methods return instances of the HypercertsStorage, HypercertIndexer, and HypercertMinter classes, respectively.

const {
  client: { storage },
} = new HypercertClient({ chain: { id: 11155111 } });

The storage is a utility class that provides methods for storing and retrieving Hypercert metadata from IPFS. It is used by the HypercertClient to store metadata when creating new Hypercerts.

const {
  client: { indexer },
} = new HypercertClient({ chain: { id: 11155111 } });

The indexer is a utility class that provides methods for indexing and searching Hypercerts based on various criteria. It is used by the HypercertClient to retrieve event-based data via the subgraph

const {
  client: { contract },
} = new HypercertClient({ chain: { id: 11155111 } });

Finally we have a contract that provides methods for interacting with the HypercertMinter smart contract. It is used by the HypercertClient to create new Hypercerts and retrieve specific on-chain information.

By providing instances of these classes through the storage, indexer, and contract getters, the HypercertClient allows developers to easily interact with the various components of the Hypercert system. For example, a developer could use the storage instance to store metadata for a new Hypercert, the indexer instance to search for existing Hypercerts based on various criteria, and the contract instance to create new Hypercerts and retrieve existing Hypercerts from the contract.