Wen? Now! A library to simplify your Web3 data fetching.

Overview

Wen Connect? Now!

Version Build Size Downloads

Minimalistic library for Web3 user interfaces.

  • Seamless connection flows to Metamask.
  • Stateless sessions that work anywhere (client, serverless, Edge Functions).
  • Respectful of user privacy. Take only the needed information, nothing more. Never saved to a DB.

Wen is about getting you to build Web3 instead of figuring out the patch work of software needed.

Usage


yarn add wen-connect
# or
npm install wen-connect --save

Wen works in all JavaScript applications, but offers different bindings for different frameworks.

React


One single context: WenProvider, and one hook: useWen for everything.

Add WenProvider to your root component:

import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import { WenProvider } from "wen-connect";

ReactDOM.render(
  <React.StrictMode>
    <WenProvider>
      <App />
    </WenProvider>
  </React.StrictMode>,
  document.getElementById("root")
);

Use the hook to engage with your user:

import { useWen } from "wen-connect";

const MyComponent = () => {
  const { connect, disconnect, wallet } = useWen();

  const handleConnect = () => {
    // Optional argument to specify which chain to get the user connected on.
    connect({ chainId: "0xa86a" });
  };

  const handleDisconnect = () => {
    disconnect();
  };

  return <span>{wallet.address}</span>;
};

wallet contains the following info:

address: string
balance: Hex string
chainId: Hex string
connected: boolean
connector: "injected"

Next.js


Wen also works server-side with Next.js to let you connect. Activate the ssr prop in the provider and add your provider to _app.tsx:

import { WenProvider } from "wen-connect";

function MyApp({ Component, pageProps }) {
  const config = { ssr: true };
  return (
    <WenProvider config={config}>
      <Component {...pageProps} />
    </WenProvider>
  );
}

Create a pages/api/wen.ts for Wen to use JWT sessions:

export { WenConnect as default } from "wen-connect";

Add a WEN_SECRET environment variable in your .env file. It will be used to encrypt the JWT token.

Now, you can get the session in getServerSideprops and use it to hydrate Wen on the client-side first render.

import { getSession, useWen } from "wen-connect";

function Index(props) {
  // Passing the session will avoid empty initial renders, saving your users loading time.
  const { wallet } = useWen(props.session);

  return <div>{wallet.address}</div>;
}

export default Index;

export const getServerSideProps = async (context) => {
  return {
    props: {
      // session.wallet is the same info as const { wallet } = useWen(props session);
      session: getSession(context),
    },
  };
};

Roadmap:

  • Signing in desired user state.
  • Svelte and SvelteKit bindings.
  • Wallet connect.
  • Coinbase wallet.
  • The graph integrations.
  • More examples.
You might also like...

A tool to simplify importing custom assets in Minecraft

BAMO - Block And Move On A tool to simplify importing custom assets in Minecraft Currently only allows you to quickly prototype models in-game, but fu

Jul 15, 2022

A browser extension to simplify web pages and hide distracting things like hide cookie banners, auto-playing videos, sidebars, etc

A browser extension to simplify web pages and hide distracting things like hide cookie banners, auto-playing videos, sidebars, etc

Unclutter Browser Extension A browser extension to simplify web pages and hide distracting things like hide cookie banners, auto-playing videos, sideb

Jan 9, 2023

It's a javascript Class which contains utility methods that simplify working with google maps web SDK

About GoogleMapsJSHelper It's a javascript Class which contains utility methods that simplify working with google maps web SDK Note: i used ES7 Class

Jul 23, 2022

Simplify the installation of a Silverstripe Dev Environment.

silverstripe docker starter Simplify the installation of a Silverstripe Dev Environment. The silverstripe docker starter is based on the silverstripe/

Jul 7, 2022

A command line application to simplify the git workflow on committing, pushing and others commands.

Git-Suite A command line application to simplify the git workflow on committing, pushing and others commands. Prerequisites Install Node Package Manag

Aug 10, 2022

Simple weather app written in HTML, CSS, and JavaScript using the OpenWeather API for fetching weather and geolocation information

Simple weather app written in HTML, CSS, and JavaScript using the OpenWeather API for fetching weather and geolocation information

Description Simple weather app written in HTML, CSS, and JavaScript using the OpenWeather API for fetching weather and geolocation information. Acknow

Feb 23, 2022

A crawler that crawls the site's internal links, fetching information of interest to any SEO specialist to perform appropriate analysis on the site.

Overview 📝 It is a module that crawls sites and extracts basic information on any web page of interest to site owners in general, and SEO specialists

Apr 22, 2022

A crawler that crawls the site's internal links, fetching information of interest to any SEO specialist to perform appropriate analysis on the site.

Overview 📝 It is a module that crawls sites and extracts basic information on any web page of interest to site owners in general, and SEO specialists

Apr 22, 2022

A cli tool for fetching information about countries.

A cli tool for fetching information about countries.

countryfetch A cli tool for fetching information about countries. It uses https://restcountries.com/ API for backend. Dependencies DENO Installation D

Dec 24, 2022
Owner
Guillaume Bibeau-laviolette
Solutions Architect @vercel: Web Development, Serverless, Finance and Data Science. Before: Shutterstock, Udacity, Filevine
Guillaume Bibeau-laviolette
Web3-citizens-app - React application based on smart contract using web3 and MetaMask extention.

Citizens App (web3-react-redux) React application based on smart contract using web3 and MetaMask extention. Start the applicarion Recomend to install

Denys Voloshyn 3 Aug 25, 2022
A web3 starter project using Typescript, Hardhat, ethers.js and @web3-react

Starter React Typescript Ethers.js Hardhat Project This repo contains a Hardhat and React Dapp starter project. The React Dapp in the frontend dir of

ChainShot 39 Dec 31, 2022
(🔗, 🌲) Web3 Link Tree is a free & open-source alternative to Linktree built with React.js, Next.js, Tailwind and Web3-React

Getting Started Read the detailed guide here Customize Add your name, wallet address, social media links and more in config.ts Images Save images to t

Naut 35 Sep 20, 2022
🛠 Solana Web3 Tools - A set of tools to improve the user experience on Web3 Solana Frontends.

?? Solana Web3 Tools - A set of tools to improve the user experience on Web3 Solana Frontends.

Holaplex 30 May 21, 2022
'event-driven' library aims to simplify building backends in an event driven style

'event-driven' library aims to simplify building backends in an event driven style(event driven architecture). For message broker, light weight Redis Stream is used and for event store, the well known NoSQL database, MongoDB, is used.

Sihoon Kim 11 Jan 4, 2023
A library to simplify the https://photop.live REST api.

Photop.js Thanks a lot to stalicites (qa#1337) for writing the documentation... Photop.js is a library created by IMPixel, and used to accomplish crea

null 5 Jul 30, 2022
A JavaScript library for EASILY fetching info from TheMovieDB API with support for torrent file names.

TheMovieDB-API-Wrapper.js A easy to use, pure vanilla JavaScript API wrapper for TheMovieDB Show your support! A JavaScript library for easily fetchin

Marketing Pipeline 5 Dec 2, 2022
🛫 TypeScript Starter template to simplify creating your next npm package.

TypeScript Starter Kit This is an opinionated TypeScript Starter kit to help kick-start development of your next npm package. ?? Get Started Luckily,

Open Web 7 Sep 27, 2022
🛫 TypeScript Starter template to simplify creating your next npm package.

TypeScript Starter Kit This is an opinionated TypeScript Starter kit to help kick-start development of your next npm package. ?? Get Started Luckily,

Open Web Foundation 5 May 19, 2022
An even simpler wrapper around native Fetch to strip boilerplate from your fetching code!

Super lightweight (~450 bytes) wrapper to simplify native fetch calls using any HTTP method (existing or imagined). Features Fully typed/TypeScript su

Kevin R. Whitley 49 Dec 28, 2022