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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@getclave/rhinestone-sdk

v0.7.15

Published

End-to-end chain abstraction and modularity toolkit

Downloads

22

Readme

Rhinestone SDK

End-to-end chain abstraction and modularity toolkit

Usage

Installation

npm install viem @rhinestone/sdk
pnpm install viem @rhinestone/sdk
yarn add viem @rhinestone/sdk
bun install viem @rhinestone/sdk

Quickstart

You'll need a Rhinestone API key, as well as an existing account with some testnet ETH on the source chain.

Creating a Wallet

Let's create a smart account with a single owner:

import { createRhinestoneAccount } from '@rhinestone/sdk'
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
import { baseSepolia, arbitrumSepolia, optimismSepolia } from 'viem/chains'
import {
  Chain,
  createPublicClient,
  createWalletClient,
  encodeFunctionData,
  erc20Abi,
  Hex,
  http,
  parseEther,
} from 'viem'

const fundingPrivateKey = process.env.FUNDING_PRIVATE_KEY
if (!fundingPrivateKey) {
  throw new Error('FUNDING_PRIVATE_KEY is not set')
}

const rhinestoneApiKey = process.env.RHINESTONE_API_KEY
if (!rhinestoneApiKey) {
  throw new Error('RHINESTONE_API_KEY is not set')
}

const sourceChain = baseSepolia
const targetChain = arbitrumSepolia

// You can use an existing PK here
const privateKey = generatePrivateKey()
console.log(`Owner private key: ${privateKey}`)
const account = privateKeyToAccount(privateKey)

const rhinestoneAccount = await createRhinestoneAccount({
  owners: {
    type: 'ecdsa',
    accounts: [account],
  }
  rhinestoneApiKey,
})
const address = await rhinestoneAccount.getAddress()
console.log(`Smart account address: ${address}`)

Funding the Account

We will send some ETH from the funding account to the created smart account. The Orchestrator will use some of that ETH to deploy the account on the target chain, as well as to convert it to USDC for a transfer transaction.

const publicClient = createPublicClient({
  chain: sourceChain,
  transport: http(),
});
const fundingAccount = privateKeyToAccount(fundingPrivateKey as Hex);
const fundingClient = createWalletClient({
  account: fundingAccount,
  chain: sourceChain,
  transport: http(),
});

const txHash = await fundingClient.sendTransaction({
  to: address,
  value: parseEther('0.001'),
});
await publicClient.waitForTransactionReceipt({ hash: txHash });

Sending a Cross-chain Transaction

Finally, let's make a cross-chain token transfer:

const usdcTarget = '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d';
const usdcAmount = 1n;

const transaction = await rhinestoneAccount.sendTransaction({
  sourceChain,
  targetChain,
  calls: [
    {
      to: usdcTarget,
      value: 0n,
      data: encodeFunctionData({
        abi: erc20Abi,
        functionName: 'transfer',
        args: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', usdcAmount],
      }),
    },
  ],
  tokenRequests: [
    {
      address: usdcTarget,
      amount: usdcAmount,
    },
  ],
});
console.log('Transaction', transaction);

const transactionResult = await rhinestoneAccount.waitForExecution(transaction);
console.log('Result', transactionResult);

After running that, you will get a smart account deployed on both Base Sepolia and Arbitrum Sepolia, and make a cross-chain USDC transfer.

Using Smart Sessions

First, define a session you want to use:

const session: Session = {
  owners: {
    type: 'ecdsa',
    accounts: [sessionOwner],
  },
  actions: [
    {
      target: wethAddress,
      selector: toFunctionSelector(
        getAbiItem({
          abi: wethAbi,
          name: 'deposit',
        }),
      ),
    },
    {
      target: wethAddress,
      selector: toFunctionSelector(
        getAbiItem({
          abi: wethAbi,
          name: 'transfer',
        }),
      ),
      policies: [
        {
          type: 'universal-action',
          rules: [
            {
              condition: 'equal',
              calldataOffset: 0n,
              referenceValue: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
            },
          ],
        },
      ],
    },
  ],
}

During account initialization, provide the session you've just created. Make sure to also provide a bundler configuration.

const rhinestoneAccount = await createRhinestoneAccount({
  // …
  sessions: [session],
  bundler: {
    // …
  },
})

When making a transaction, specify the signers object to sign it with the session key:

const transactionResult = await rhinestoneAccount.sendTransaction({
  // …
  signers: {
    type: 'session',
    session: session,
  },
})

Contributing

For feature or change requests, feel free to open a PR, start a discussion or get in touch with us.