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 🙏

© 2026 – Pkg Stats / Ryan Hefner

rituals-sdk

v0.1.14

Published

Ritual Protocol SDK

Readme

Rituals SDK

Rituals SDK is a Typescript SDK that makes it easy to build applications on top of Rituals smart contracts. You can use Rituals contracts to host challenges and token gated communities and tournaments.

Architecture

Alt

Installation

Install the package with npm in your terminal:

npm install rituals-sdk

Once it's installed, import the module into your project as shown below.

import Rituals from 'rituals-sdk';
// or
const Rituals = require('rituals-sdk');

Quick examples

Get Rituals By Creator

This code fetches all published.

// you provide these values
const infuraKey = 'your-infura-api-key';
const privateKey = '0xf00...';

const ritualService = await Rituals.initialize('https', {
  url: `https://mainnet.infura.io/v3/${infuraKey}`,
  privateKey,
  chainId: 1,
});

const result = ritualService.getPublishedRituals();
console.log(result);

Rituals.initialize

You can configure the behavior of Rituals SDK by passing different arguments to Rituals.initialize. The first argument is the name of a preset, and the second is an options object.

Presets

  • 'browser' Use this preset when using the library in a browser environment. It will attempt to connect using window.ethereum or window.web3. Make sure you pass in the connected browser provider instance

  • 'https' Connect to a JSON-RPC node. Requires url to be set in the options.

  • 'custom' Connect to a custom transport.

// browser
const ritualService = await Rituals.initialize('browser');

// https
const ritualService = await Rituals.initialize('https');

// custom transport, for example, privy
const ritualService = await Rituals.initialize('custom', {
  chainId: currentChain.id,
  customProvider: provider,
  account: wallet.account?.address,
});

Options

  • privateKey
    • Optional. The private key used to sign transactions. If this is omitted, the first account available from the Ethereum provider will be used. Only used with the 'https' preset.
    • If this is omitted and the provider does not have an unlocked account, the Rituals object will start in read-only mode.
  • url
    • The URL of the node to connect to. Only used with the 'http' preset.
  • account
    • An account object containing an address, 0xaddress.
  • chainId
    • The chainId to connect to. Must match a supported chain.

API Reference

RitualService

This class encapsulates interactions with the Ritual Service contract with maintains and index of all rituals that have been created and tracks them by creator and membership.

createAndInitializeRitual

creates a new ritual contract and returns the address of the new contract.

const ritualAddress = await rs.createAndInitializeRitual({
  title: 'Hot Girl Summer Walk',
  description: 'Coming in hottt 🔥',
  isPrivate: false,
  startDate: BigInt(17402846583920),
  endDate: BigInt(17402846584819),
  joinCutoff: BigInt(0),
  capacity: BigInt(250),
  tags: ['hot', 'girl', 'summer', 'walk'],
  schedule: [
    { day: Day.MON.valueOf(), timeInSeconds: BigInt(0) },
    { day: Day.TUE.valueOf(), timeInSeconds: BigInt(27000) },
    { day: Day.WED.valueOf(), timeInSeconds: BigInt(0) },
    { day: Day.THU.valueOf(), timeInSeconds: BigInt(27000) },
    { day: Day.FRI.valueOf(), timeInSeconds: BigInt(0) },
    { day: Day.SAT.valueOf(), timeInSeconds: BigInt(27000) },
    { day: Day.SUN.valueOf(), timeInSeconds: BigInt(0) },
  ],
});

getRItualsByCreator

const publishedRituals = await ritualService.getRItualsByCreator(`0x{address}`);

getRitualsWhereMember

const publishedRituals = await ritualService.getRitualsWhereMember(`0x{address}`);

getPublishedRituals

const rituals = await ritualService.getPublishedRituals();

getActivities

returns a list of available activities to attest to

const activities = await ritualService.getActivities();

getActivity

const activity = await ritualService.getActivity('running');
console.log(activity.label, ' has ', activity.availableMetrics.length, ' trackable metrics');

deleteDraft

const tx_hash = await ritualService.deleteDraft(`0xcontractAddress`);
if (tx_hash) console.log('draft deleted');

getRitualInstance

// connect to a ritual contract
const ritual = ritualService.getRitualInstance(`0x{address}`);

// get the ritual's details
const ritualInfo = await ritual.get();
console.log(ritualInfo.title, ' starts on ', ritualInfo.startTime);

Ritual

This class supoorts interactions with an individual Ritual contract and encapsulates admin interactions like initializing, setting fields and publishing as well as membership interactions like joining, leaving and claiming rewards.

publish

// publish a ritual to make it joinable
const tx_hash = await ritual.publish();
if (tx_hash) console.log('publish successful');

join

// try joining a ritual
const tx_hash = await ritual.join();
if (tx_hash) console.log('join successful');

leave

// leave the ritual
const tx_hash = await ritual.leave();
if (tx_hash) console.log('leave successful');

get

// get the ritual's details
const ritualInfo = await ritual.get();
console.log(
  ritualInfo.title,
  ' starts on ',
  ritualInfo.startTime,
  ' and lives at ',
  ritualInfo.ritualAddress,
  ' and has ',
  ritualInfo.members.length,
  ' members.',
);
console.log('Memeber 1 is ' ritualInfo.members[0].account);

addGoal

const tx_hash = await ritual.addGoal('running', 'distance', 500000, 'to a bagel shop each day');

addTags

const tx_hash = await ritual.addTags('hotgirlsummer', 'walking', 'nyc');

setStartDate

const offsetInDays = 10;
const timeInSeconds = Math.floor((Date.now() + offsetInDays * 86400000) / 1000);
const tx_hash = await ritual.setStartDate(BigInt(timeInSeconds));
if (tx_hash) console.log('set start date successful');

setEndDate

const offsetInDays = 40;
const timeInSeconds = Math.floor((Date.now() + offsetInDays * 86400000) / 1000);
const tx_hash = await ritual.setEndDate(BigInt(timeInSeconds));
if (tx_hash) console.log('set end date successful');

setMetadata

const tx_hash = await ritual.setMetadata('coverPhoto', 'https://picsum.photos/500/200');