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

@chainsafe/open-creator-rails-sdk

v0.1.0

Published

TypeScript SDK for interacting with Open Creator Rails contracts and indexer.

Readme

Open Creator Rails SDK

TypeScript SDK for interacting with Open Creator Rails

Install

Published on npm as @chainsafe/open-creator-rails-sdk.

pnpm add @chainsafe/open-creator-rails-sdk viem
# npm install @chainsafe/open-creator-rails-sdk viem

Quick start

import { createPublicClient, createWalletClient, http } from "viem";
import { sepolia } from "viem/chains";
import { OcrSdk } from "@chainsafe/open-creator-rails-sdk";

const publicClient = createPublicClient({
  chain: sepolia,
  transport: http(process.env.RPC_URL!),
});

const walletClient = createWalletClient({
  chain: sepolia,
  transport: http(process.env.RPC_URL!),
  account: /* your account */,
});

const sdk = new OcrSdk({
  publicClient,
  walletClient,
  registryAddress,
  indexerUrl: process.env.INDEXER_URL, // optional
});

API overview

The SDK exposes:

  • Namespaced contract APIs
    • sdk.AssetRegistry.* wraps AssetRegistry contract methods
    • sdk.Asset.* wraps Asset contract methods
  • Bound "Asset client" helper
    • sdk.getAsset({ assetAddress }) and sdk.getAssetById({ assetId }) return an object that remembers assetAddress.
  • Indexer namespace
    • sdk.indexer.* exposes indexer-only queries that are not possible with simple onchain reads.

Namespaced contract usage

// AssetRegistry reads
const assetAddress = await sdk.AssetRegistry.getAsset({ assetId });
const exists = await sdk.AssetRegistry.viewAsset({ assetId });

// Asset reads (namespace form)
const owner = await sdk.Asset.owner({ assetAddress });
const token = await sdk.Asset.getTokenAddress({ assetAddress });

// Asset reads (bound client form)
const asset = sdk.getAsset({ assetAddress }); // or: await sdk.getAssetById({ assetId })
await asset.setSubscriptionPrice({ newSubscriptionPrice: 123n });

Write methods (require walletClient)

All write methods require walletClient in the SDK config and walletClient.account to be set.

await sdk.AssetRegistry.updateCreatorFeeShare({ creatorFeeShare: 60n });
await sdk.Asset.setSubscriptionPrice({ assetAddress, newSubscriptionPrice: 123n });

// Or with the bound asset client:
await asset.setSubscriptionPrice({ newSubscriptionPrice: 123n });

Indexer support

If you pass indexerUrl, the SDK exposes a dedicated indexer namespace at sdk.indexer.

Indexer namespace (sdk.indexer)

if (!sdk.indexer) throw new Error("indexerUrl not configured");

// Subscription for a specific asset + user
const sub = await sdk.indexer.getSubscription({ assetAddress, user });

// All subscriptions for a user (across assets), optionally only active ones
const activeSubs = await sdk.indexer.listSubscriptionsByUser({ user, activeOnly: true });

// Asset metadata (indexed)
const assetEntity = await sdk.indexer.getAsset({ assetAddress });

// Assets indexed for a registry
const assetsInRegistry = await sdk.indexer.listAssetsByRegistry({ registryAddress });

Source selection

Some methods accept source?: "auto" | "onchain" | "indexer":

  • "auto" (default): try indexer (if configured), then fall back to onchain
  • "onchain": only onchain reads
  • "indexer": only indexer; throws if the indexer request fails

Indexer-backed reads

These methods are implemented with indexer-first + fallback behavior:

// Subscription status by assetId + user
const status = await sdk.getSubscriptionStatus({ assetId, user, source: "auto" });

// Subscription status by assetAddress + user
const status2 = await sdk.Asset.getSubscriptionStatus({ assetAddress, user, source: "auto" });

// Asset owner by assetAddress
const owner2 = await sdk.Asset.getOwner({ assetAddress, source: "auto" });

Local Node (Anvil) + SDK Testing

This SDK can be tested end-to-end against a local Anvil chain using the contracts from the open-creator-rails submodule.

Prerequisites

  1. Install Foundry (provides anvil + forge).
  2. Initialize the contracts submodule:
npm run submodule:pull

Run integration tests (recommended)

These tests start Anvil, deploy TestToken and AssetRegistry, run subscribe/getSubscriptionStatus, advance time, and then run claimCreatorFee.

npm run test:integration

Manual debugging (optional)

Start Anvil on the default port:

anvil --chain-id 31337 --port 8545

Then point your SDK clients at it (as shown in the Usage section above) by setting:

export RPC_URL=http://127.0.0.1:8545

Maintenance

Updating git submodules

This repo includes the open-creator-rails submodule (contracts + deployment JSON). When upstream main changes, update the submodule and commit the new submodule SHA value (gitlink) in this repo.

Recommended update workflow

  1. Pull the latest submodule commits:
npm run submodule:pull
  1. Commit the updated gitlink SHAs in this repository:
git status
git add open-creator-rails
git commit -m "chore: update submodules"

Publishing to npm

Package: @chainsafe/open-creator-rails-sdk (public, ChainSafe org).

pnpm install
pnpm run build
pnpm run test
pnpm run lint
npm version patch   # or minor / major
git push && git push --tags
npm publish --access public

Requires npm login as a user with publish access to the @chainsafe scope. prepack builds dist/ automatically before pack/publish.