Wen Actions
Wen Tools are under heavy development
Straight forward, batteries includes utilities to build dapps.
For a turnkey connect component see: Wen React
Getting started
Wen Actions depends on no other libraries to get started. It can completely be used as a standalone library but it works well with ethers.jsx
npm i @wen-tools/actions# oryarn add @wen-tools/actions# orpnpm i @wen-tools/actions
Interacting with a user's wallet
All functions are asynchronous.
import { connectWallet, changeChain } from "@wen-tools/actions";
// request a connectionconnectWallet();// request the user to change to ethereumchangeChain("0x1");
Reading data from the user's wallet
Wen Actions support both vanilla js and react.
JS/TS
A readonly proxy object is exposed to work.
import { state } from "@wen-tools/actions";
// state is an instance of Statetype State = { metamaskPresent: Promise<boolean>; address: string | null; balance: string | null; connected: boolean; chainId: string | null; // anytime the state is waiting on an updte from metamask, requesting is true requesting: boolean;};
React
For reactive updates use the React hook. It exposes the same state as the vanilla js/ts proxy object.
import { useWen } from "@wen-tools/react";
export default function Home() { // anytime the state is waiting on an updte from metamask, requesting is true const { address, balance, connected, chainId, requesting } = useWen(); return <div>{address}</div>;}