Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stackr/pointy

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stackr/pointy

Pointy Client SDK

  • 0.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
0
Weekly downloads
 
Created
Source

@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);

Keywords

FAQs

Package last updated on 10 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc