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

@oasisprotocol/sapphire-wagmi-v2

v3.0.0

Published

Wagmi & Viem support for the Oasis Sapphire ParaTime.

Downloads

275

Readme

Sapphire Wagmi v2

version size downloads

A plugin for Wagmi v2 that provides seamless integration with the Oasis Sapphire network, enabling end-to-end encryption for transactions and gas estimations. This package wraps providers and connectors to automatically encrypt data when interacting with Sapphire networks.

Usage

Installation

Install the package along with required peer dependencies:

npm install @oasisprotocol/sapphire-wagmi-v2 [email protected] [email protected]

EIP-6963 Multi Injected Provider Discovery

Single chain - Sapphire

The primary way to use this library is by wrapping existing Wagmi connectors with wrapConnectorWithSapphire(). It is recommended to modify the connector name to differentiate it from "unwrapped" connectors. This works with any connector type (MetaMask, WalletConnect, Coinbase Wallet, etc.):

import { createConfig } from "wagmi";
import { sapphire, sapphireTestnet } from "wagmi/chains";
import { metaMask, walletConnect } from "@wagmi/connectors";
import {
  wrapConnectorWithSapphire,
  sapphireHttpTransport
} from "@oasisprotocol/sapphire-wagmi-v2";

export const wagmiConfig = createConfig({
  chains: [sapphire, sapphireTestnet],
  connectors: [
    wrapConnectorWithSapphire(
      metaMask,
      {
        id: 'metamask-sapphire',
        name: 'MetaMask (Sapphire)',
      }
    ),
    wrapConnectorWithSapphire(
      () => walletConnect({ projectId: 'your-project-id' }),
      {
        id: 'walletconnect-sapphire',
        name: 'WalletConnect (Sapphire)',
      }
    ),
  ],
  transports: {
    [sapphire.id]: sapphireHttpTransport(),
    [sapphireTestnet.id]: sapphireHttpTransport(),
    [sapphireLocalnet.id]: sapphireHttpTransport(),
  },
});

Multichain

For applications supporting both Sapphire and non-Sapphire networks, wrapConnectorWithSapphire automatically detects the chain and only applies encryption when connected to Sapphire networks. This allows you to use a single wrapped connector for both Sapphire and non-Sapphire chains:

import { createConfig } from "wagmi";
import { sapphire, mainnet } from "wagmi/chains";
import { metaMask } from "@wagmi/connectors";
import {
  wrapConnectorWithSapphire,
  sapphireHttpTransport,
  sapphireLocalnet
} from "@oasisprotocol/sapphire-wagmi-v2";
import { http } from "wagmi";

export const wagmiConfig = createConfig({
  chains: [sapphire, sapphireLocalnet, mainnet],
  connectors: [
    // Sapphire-wrapped aware MetaMask for Sapphire chains, unwrapped for other chains
    wrapConnectorWithSapphire(
      metaMask(),
      {
        id: 'metamask-sapphire',
        name: 'MetaMask (Sapphire)',
      }
    ),
  ],
  transports: {
    [sapphire.id]: sapphireHttpTransport(),
    [sapphireLocalnet.id]: sapphireHttpTransport(),
    [mainnet.id]: http(),
  },
});

EIP-1193 Injected provider

In your Wagmi config definition, wrap the injected provider for Sapphire using injectedWithSapphire().

import { createConfig } from "wagmi";
import { sapphire, sapphireTestnet } from "wagmi/chains";
import {
  injectedWithSapphire,
  sapphireHttpTransport,
  sapphireLocalnet
} from "@oasisprotocol/sapphire-wagmi-v2";

export const wagmiConfig = createConfig({
  multiInjectedProviderDiscovery: false,
  chains: [sapphire, sapphireTestnet, sapphireLocalnet],
  connectors: [injectedWithSapphire()],
  transports: {
    [sapphire.id]: sapphireHttpTransport(),
    [sapphireTestnet.id]: sapphireHttpTransport(),
    [sapphireLocalnet.id]: sapphireHttpTransport()
  },
});

View-calls data encryption

Use a public client with createPublicClient() and for read-only operations like querying blockchain data and calling view functions without requiring a wallet. The Sapphire transport is still necessary even for read operations to properly handle end-to-end encryption when accessing private contract state or making view calls that return encrypted data.

import {
  sapphireHttpTransport,
  wrapWalletClient,
  createSapphireSerializer,
  sapphireLocalnet
} from '@oasisprotocol/sapphire-wagmi-v2';
import { createWalletClient } from 'viem';

// Create a Sapphire-enabled HTTP transport
const transport = sapphireHttpTransport();

const client = await wrapWalletClient(
  createWalletClient({
    account,
    chain: sapphireLocalnet,
    transport: sapphireHttpTransport()
  })
);

For a complete example of how to use this library, please refer to our Wagmi example. In case you want to integrate with a 3rd wallet library, also see the Wagmi example for how to do so, as the example for Rainbowkit is provided.