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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@buildersgarden/privy-wagmi-provider

v0.7.0

Published

React native provider for using Privy + Wagmi in your native app.

Downloads

17

Readme

🌳 @buildersgarden/privy-wagmi-provider

React native provider for using Privy + Wagmi in your native app.

📦 Installation

npm install @buildersgarden/privy-wagmi-provider # using npm
yarn add @buildersgarden/privy-wagmi-provider # using yarn
bun add @buildersgarden/privy-wagmi-provider # using bun

🤝 Peer dependencies

This project has some peer dependencies that you need to install in your app in order to make it work:

npm install @tanstack/react-query wagmi viem # using npm
yarn add @tanstack/react-query wagmi viem # using yarn
bun add @tanstack/react-query wagmi viem # using bun

Once the package and its peer dependencies are installed in your app, you must import the following polyfills in your app entrypoint:

import 'fast-text-encoding';
import 'node-libs-expo/globals';
import 'react-native-url-polyfill/auto';
import 'react-native-get-random-values';
import '@ethersproject/shims';

In case you don't already have these polyfills installed, make sure to run the following command:

npm install fast-text-encoding node-libs-expo react-native-url-polyfill react-native-get-random-values @ethersproject/shims # using npm
yarn add fast-text-encoding node-libs-expo react-native-url-polyfill react-native-get-random-values @ethersproject/shims # using yarn
bun add fast-text-encoding node-libs-expo react-native-url-polyfill react-native-get-random-values @ethersproject/shims # using bun

🛠️ Usage

You can use the PrivyWagmiProvider component in your app to start connecting the user and to use the wagmi hooks inside your react native app.

import React from 'react';
import { PrivyWagmiProvider } from '@buildersgarden/privy-wagmi-provider';
import { QueryClient } from '@tanstack/react-query';
import { WagmiProvider, createConfig, http } from 'wagmi';
import { base } from 'viem/chains';

const queryClient = new QueryClient();

const wagmiConfig = createConfig({
  chains: [base],
  transports: {
    [base.id]: http(),
  },
});

export default function App() {
  return (
    <PrivyWagmiProvider config={wagmiConfig} queryClient={queryClient}>
      {/* Your app */}
    </PrivyWagmiProvider>
  );
}

Then you can use the usePrivyWagmiProvider hook to connect the user wallet:

import { usePrivyWagmiProvider } from '@buildersgarden/privy-wagmi-provider';

/* your code */

const { connect, isConnected, isReady, wallet, address } =
  usePrivyWagmiProvider();

/* your code */

🪙 useERC20 hooks

The library comes with several useful hooks to interact with ERC20 tokens. This is a list of the hooks available:

  • useERC20Transfer - hook to transfer ERC20 tokens;
  • useERC20TransferFrom- hook to transfer ERC20 tokens from an address to another;
  • useERC20Approve- hook to approve ERC20 tokens spending;
  • useERC20Allowance - hook to get the allowance of an address to spend ERC20 tokens;
  • useERC20BalanceOf - hook to get the balance of an address for an ERC20 token;
  • useERC20TotalSupply - hook to get the total supply of an ERC20 token;
  • useERC20Decimals - hook to get the decimals of an ERC20 token;
  • useERC20Symbol - hook to get the symbol of an ERC20 token.

These hooks are just wrappers around the useWriteContract and useReadContract hooks provided by wagmi. In case you need more control over the contract interaction, you should use the "native" hooks directly.

🖼️ useERC721 hooks

The library comes with several useful hooks to interact with ERC721 tokens. This is a list of the hooks available:

  • useERC721Transfer - hook to transfer ERC721 tokens;
  • useERC721Approve- hook to approve ERC721 tokens spending;
  • useERC721Allowance - hook to get the allowance of an address to spend ERC721 tokens;
  • useERC721BalanceOf - hook to get the balance of an address for an ERC721 token;
  • useERC721TotalSupply - hook to get the total supply of an ERC721 token;
  • useERC721TokenURI - hook to get the token URI of an ERC721 token;
  • useERC721OwnerOf - hook to get the owner of an ERC721 token;
  • useERC721Symbol - hook to get the symbol of an ERC721 token.

👇 Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.