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

@stackr/pointy

v0.1.5

Published

Pointy Client SDK

Downloads

19

Readme

@stackr/pointy

A TypeScript SDK to interact with the Pointy service.

Installation

npm install @stackr/pointy

Setup SDK

import { PointyClient } from "@stackr/pointy";
import dotenv from "dotenv";

dotenv.config();

const client = new PointyClient({
  apiKey: process.env.API_KEY,
  appId: <appId>,
  signer: process.env.PRIVATE_KEY,
});

can optionally pass in ethereumRpcUrl value to be used for resolving ENS names.

Usage

These operations can be performed from the dashboard as well.

Create an Event

const { event } = await client.createEvent({
  name: "sign_up",
  points: 10,
});

Grant Points

const { eventLog } = await client.logEvent({
  event: "sign_up",
  user: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", // or "vitalik.eth"
});

Create an event with onchain trigger (EVM log)

const { event } = await client.createEventWithOnChainTrigger({
  name: "uniswapv2_transfer",
  points: 10,
  chainId: 1,
  chainContract: "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
  chainEventAbi:
    "event Transfer(address indexed from, address indexed to, uint value)",
  chainEventUserField: "from",
});

Retrieving Data

Get leaderboard

const { leaderboard, pageInfo } = await client.getLeaderboard({
  page: 1,
  pageSize: 10,
});

Get activity

const { activity, pageInfo } = await client.getActivity({
  page: 1,
  pageSize: 10,
});

Get activity for a user

const { activity, pageInfo } = await client.getActivityForUser(
  "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
); // or "vitalik.eth"

Get points for a user

const { points } = await client.getPoints(
  "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
); // or "vitalik.eth"

List all event types

const { eventTypes } = await client.getEventTypes();

Advanced

Get a rollup action and block details

const { action } = await client.getAction("0x642066dacd3a848af5a7f5e07bef7c982a735f388273be71065e2b2cfed5c3be");

State Proofs

Retrieve a proof of user's points

const { userLeaf, userPointsProof, stateProof } = await client.retrieveProof(
  "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
); // or "vitalik.eth"

Generate a proof of user's points locally

const { userLeaf, userPointsProof, stateProof } = await client.generateLocalProof(
  "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
); // or "vitalik.eth"

Generate a proof of user's points fully locally by providing state

import { generateLocalProof, PointyState } from "@stackr/pointy";

const state: PointyState = {...};
const { userLeaf, userPointsProof, stateProof } = generateLocalProof(
  "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
  state
);

Compute the rollup's state root locally

const stateRoot = await client.computeStateRoot();

Compute the rollup's state root fully locally by providing state

import { computeStateRoot, PointyState } from "@stackr/pointy";

const state: PointyState = {...};
const stateRoot = computeStateRoot(state);