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

@chainvine/sdk

v1.6.1

Published

SDK for integrating with app.chainvine.xyz

Downloads

1,095

Readme

@ChainVine SDK

A light client for interacting with the ChainVine API (note: you will need an active subscription for ChainVine in order to utilise the SDK).

Installation

npm install @chainvine/sdk

Usage

There are two methods of interacting with the ChainVine API, either by providing a Chainvine API Key (available under 'Community Settings' from your admin dashboard) or by omitting the API key and ensuring all requests are sent from a previously whitelisted domains (these can also be managed under 'Community Settings' from your admin dashboard).

It is advised to use the API key method as it is more secure and allows you to use the SDK from any domain, but only if you are operating from a server context (i.e. from an API) as you do not want to expose your API key in a browser.

Should you be using the ChainVine SDK on the browser side you will need to follow the domain whitelisting approach.

Please consult the documentation for usage and integration details: https://docs.chainvine.xyz/developers/sdk

import { ChainvineClient } from '@chainvine/sdk/lib';

// Initialise the client (without an API key or any overriden settings)
const client = new ChainvineClient();

//OR, Initialise the client with an API key and/or supply some config
const client = new ChainvineClient({
  apiKey: '<YOUR API KEY>', //optional, if not provided you will need to whitelist your domain from your admin dashboard
  testMode: true, // optional, defaults to false. When set to true, the SDK will use the test API endpoint
  logToConsole: true, // optional, defaults to false. When set to true, the SDK will log errors and requests/responses to the console (useful for development and debugging)
});

// All user-specific actions require a userClient
const user_wallet = '0x1234567890';
const userClient = await client.syncUser(user_wallet)

Helper functions

We offer some helper functions to make integration with ChainVine easier.

Note: these helper functions rely on browser functionality and must be executed client-side.

Store a Referrer Code for future use

This will create a CV_REF cookie for you (which will expire in 120 days by default) you can either interrogate requests to your API for this if you are using the SDK from your API or call getReferrerId() to fetch when you need it in your browser

import { storeReferrer } from '@chainvine/sdk';

storeReferrer(); //This will fetch the r query parameter from the current URL (if available) and store it in a CV_REF cookie

You may customise the cookie settings as follows:

storeReferrer({
  durationDays: 30, //Override the default cookie duration (120 days)
  ref: 'ABC123', //Should you already have access to the referrer code, and if you do not want it fetched from the URL, you can provide it directly
}); 
Retrieve a previously stored Referrer Code
import { getReferrer } from '@chainvine/sdk';

//Fetches a previously stored referrer code from the CV_REF cookie if available, returns undefined if not
getReferrer(); 
Clear a stored Referrer Code
import { clearReferrer } from '@chainvine/sdk';

//Clear the CV_REF cookie:
clearReferrer();
A browser use-case might then look something like:
import { ChainvineClient } from '@chainvine/sdk/lib';
import { getReferrer, storeReferrer } from '@chainvine/sdk';

const client = new ChainvineClient();

... 

//Fetch and store the referrer_id from the URL on page load:
storeReferrer();

...

//When a user connects their wallet (or at any point once you have access to their wallet address) 
//Note: this could be a completely different page or flow to the one where the referrer was stored
const user = await client.syncUser('0x1234567890')
const referral = await user.referral({campaign}).linkReferrer(getReferrer());