GithubHelp home page GithubHelp logo

graz-sh / graz Goto Github PK

View Code? Open in Web Editor NEW
102.0 7.0 27.0 9.32 MB

React hooks for Cosmos ๐Ÿช

Home Page: https://graz.sh/

License: MIT License

JavaScript 5.05% TypeScript 93.96% HTML 0.17% CSS 0.82%
graz keplr keplr-wallet react-cosmos-hooks use-keplr cosmjs cosmos cosmos-sdk leap leap-wallet wallet-connect vectis vectis-wallet

graz's Introduction

graz

npm/v npm/dt stars

graz is a collection of React hooks containing everything you need to start working with the Cosmos ecosystem.

Features

  • ๐Ÿช 20+ hooks for interfacing with wallets, clients, signers, etc. (connecting, view balances, send tokens, etc.)
  • ๐Ÿ’ณ Multiple wallet supports (Keplr, Leap, Cosmostation, Vectis, Station, XDefi, Metamask Snap, WalletConnect)
  • โš™๏ธ Generate mainnet & testnet ChainInfo
  • ๐Ÿ“š Built-in caching, request deduplication, and all the good stuff from @tanstack/react-query and zustand
  • ๐Ÿ”„ Auto refresh on wallet and network change
  • ๐Ÿ‘ Fully typed and tree-shakeable
  • ...and many more โœจ

Requirements

graz requires react@>=17 due to using function components and hooks and the new JSX transform.

Installing

Install graz using npm, yarn, or pnpm:

# using npm
npm install graz

# using yarn
yarn add graz

# using pnpm
pnpm add graz

Install peer dependencies

To avoid version mismatch we decided to make these packages as peer dependencies:

# using npm
npm install @cosmjs/cosmwasm-stargate @cosmjs/launchpad @cosmjs/proto-signing @cosmjs/stargate @cosmjs/tendermint-rpc long

# using yarn
yarn add @cosmjs/cosmwasm-stargate @cosmjs/launchpad @cosmjs/proto-signing @cosmjs/stargate @cosmjs/tendermint-rpc long

# using pnpm
pnpm add @cosmjs/cosmwasm-stargate @cosmjs/launchpad @cosmjs/proto-signing @cosmjs/stargate @cosmjs/tendermint-rpc long

Quick start

Wrap your React app with <GrazProvider /> and use available graz hooks anywhere:

import { GrazProvider } from "graz";

const cosmoshub: ChainInfo = {
  chainId: "cosmoshub-4",
  chainName: "Cosmos Hub",
  //... rest of cosmoshub ChainInfo
}

function App() {
  return (
    <GrazProvider grazOptions={{
      chains: [cosmoshub]
    }}>
      <Wallet />
    </GrazProvider>
  );
}
import { mainnetChains, useAccount, useConnect, useDisconnect } from "graz";

function Wallet() {
  const { connect, status } = useConnect();
  const { data: account, isConnected } = useAccount();
  const { disconnect } = useDisconnect();

  function handleConnect() {
    return isConnected ? disconnect() : connect();
  }

  return (
    <div>
      {account ? `Connected to ${account.bech32Address}` : status}
      <button onClick={handleConnect}>{isConnected ? "Disconnect" : "Connect"}</button>
    </div>
  );
}

Examples

API

You can read more about available hooks and exports on Documentation Site or via paka.dev.

Maintainers

License

MIT License, Copyright (c) 2023 Graz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.