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

@solrengine/wallet-utils

v0.3.5

Published

Wallet discovery, transaction building, signing utilities, and Stimulus controllers for Solana + Rails apps

Readme

@solrengine/wallet-utils

Wallet discovery, transaction building, and Stimulus controllers for Solana + Rails apps.

Part of the SolRengine framework.

Install

yarn add @solrengine/wallet-utils

Peer dependencies (already in SolRengine apps):

yarn add @hotwired/stimulus @hotwired/turbo @solana/kit @solana/wallet-standard-features @wallet-standard/app

Stimulus Controllers

Ready-made controllers for Solana dApps built with Rails + Hotwire.

import { application } from "./application"
import {
  WalletController,
  AutoRefreshController,
  ClipboardController,
  CountdownController
} from "@solrengine/wallet-utils/controllers"

application.register("wallet", WalletController)
application.register("auto-refresh", AutoRefreshController)
application.register("clipboard", ClipboardController)
application.register("countdown", CountdownController)

WalletController

SIWS (Sign In With Solana) authentication. Discovers wallets via Wallet Standard, uses legacy provider for Chrome popup compatibility.

<div data-controller="wallet"
     data-wallet-nonce-url-value="<%= auth_nonce_path %>"
     data-wallet-verify-url-value="<%= auth_verify_path %>"
     data-wallet-dashboard-url-value="<%= dashboard_path %>">

  <div data-wallet-target="walletList" class="hidden"></div>
  <div data-wallet-target="status" class="hidden"></div>

  <button data-wallet-target="connectBtn"
          data-action="click->wallet#authenticate">
    Connect Wallet
  </button>

  <div data-wallet-target="signing" class="hidden">
    Approve in your wallet...
  </div>
</div>

Values: nonceUrl, verifyUrl, dashboardUrl Targets: connectBtn, signing, status, walletList

AutoRefreshController

Invisible page refresh using Turbo morphing. Fetches fresh HTML and morphs only changed elements — no loading bar, no scroll reset.

<div data-controller="auto-refresh" data-auto-refresh-interval-value="60">
  <!-- content morphs every 60 seconds -->
</div>

Values: interval (seconds, default: 60)

ClipboardController

Copy text to clipboard with visual feedback.

<button data-controller="clipboard"
        data-clipboard-text-value="<%= @address %>"
        data-action="click->clipboard#copy">
  <span data-clipboard-target="label">Copy</span>
</button>

Values: text Targets: label

CountdownController

Live countdown timer with progress bar. Persists state in sessionStorage to survive morphs and reloads.

<div data-controller="countdown"
     data-countdown-expires-at-value="<%= lock.exp %>"
     data-countdown-expired-value="false">
  <div data-countdown-target="badge">Locked</div>
  <div data-countdown-target="progress" style="width: 0%"></div>
  <span data-countdown-target="timer">Calculating...</span>
</div>

Values: expiresAt (unix timestamp), expired (boolean) Targets: timer, progress, badge

Wallet Utilities

Functions for wallet discovery and connection.

import {
  discoverWallets,
  findWalletByAddress,
  connectWallet,
  connectWithLegacy,
  getLegacyProvider,
} from "@solrengine/wallet-utils"

findWalletByAddress(address)

Find a wallet + account matching a given address. Tries exposed accounts first, then connects to each wallet.

const { wallet, account } = await findWalletByAddress("Fqgr...HC12")

discoverWallets(feature, onRegister)

List all wallets supporting a given feature. Optionally listen for new wallets.

import { SolanaSignAndSendTransaction } from "@solana/wallet-standard-features"

const wallets = discoverWallets(SolanaSignAndSendTransaction, (newWallets) => {
  console.log("New wallets:", newWallets)
})

connectWallet(wallet)

Connect to a wallet and return the first account.

const { wallet, account } = await connectWallet(selectedWallet)

getLegacyProvider(walletName)

Get the legacy window provider for Chrome popup compatibility.

const provider = getLegacyProvider("Phantom") // window.phantom.solana

Transaction Utilities

Build and send Solana transactions with @solana/kit.

import {
  buildTransferTransaction,
  buildTransferInstruction,
  buildProgramInstruction,
  compileTransactionMessage,
  toWireBytes,
  signAndSend,
  detectChain,
  explorerUrl,
  getCsrfToken,
} from "@solrengine/wallet-utils"

buildTransferTransaction({ sender, recipient, amountSol, blockhash, lastValidBlockHeight })

Build a complete SOL transfer as wire-format bytes, ready for wallet signing.

const txBytes = buildTransferTransaction({
  sender: account.address,
  recipient: "ABC...xyz",
  amountSol: 0.5,
  blockhash,
  lastValidBlockHeight
})

buildProgramInstruction({ programId, instructionData, accounts })

Build a custom program instruction from server-provided data. Decodes base64 instruction data and maps account roles.

const instruction = buildProgramInstruction({
  programId: "ZaU8j...",
  instructionData: response.instruction_data, // base64
  accounts: response.accounts // [{pubkey, is_signer, is_writable}]
})

compileTransactionMessage({ feePayer, blockhash, lastValidBlockHeight, instruction, version })

Compile an instruction into a transaction.

const compiled = compileTransactionMessage({
  feePayer: account.address,
  blockhash,
  lastValidBlockHeight,
  instruction,
  version: "legacy" // or 0
})

signAndSend({ wallet, account, transaction, chain })

Sign and send a transaction via wallet-standard. Returns the signature as a base58 string.

const signature = await signAndSend({
  wallet, account,
  transaction: toWireBytes(compiled),
  chain: "solana:devnet"
})

Helper functions

detectChain("https://api.devnet.solana.com")  // "solana:devnet"
explorerUrl(signature, "solana:devnet")         // "https://explorer.solana.com/tx/...?cluster=devnet"
explorerUrl(signature, "solana:mainnet")         // "https://solscan.io/tx/..."
getCsrfToken()                                   // Rails CSRF token from meta tag
toWireBytes(compiled)                             // compiled transaction → Uint8Array

License

MIT