Giter Club home page Giter Club logo

hedera-react's Introduction

hedera-react ๐Ÿงฐ

A simple, maximally extensible, dependency minimized framework for building modern Hedera dApps

lerna code style: prettier

| ๐Ÿ  Core | @hedera-react/core

| ๐Ÿ”Œ Connectors @hedera-react/flash

Installation

yarn add @hedera-react/core @hedera-react/flash @hedera-react/hashconnect @hedera-react/store 

Initialisation

Following steps are required to integrate flash wallet to your dapp.

Create a connector file


import { initializeConnector } from "@hedera-react/core";
import { FlashConnect } from "@hedera-react/flash";

export const [flashConnector, hooks] = initializeConnector<FlashConnect>(
  (actions) =>
    new FlashConnect({
      actions,
      clientMeta: {
        description: "Flash Wallet Demo",
        url: "https://flash-demo.vercel.app",
        icons: ["https://mintmaster.s3.us-east-1.amazonaws.com/flash.png"],
        name: "Flash Demo",
      },
    })
);

Usage

Call the flashConnector from connector file in the useEffect of the component

import { flashConnector } from '../../connectors/flashConnector';

  useEffect(() => {
    if (flashConnector.connectEagerly) {
      flashConnector.connectEagerly().catch(() => {
        console.debug("Failed to connect eagerly to walletconnect");
      });
    }
  }, []);
  

Activating the wallet

  <WalletBtn
    onClick={() => {
        flashConnector.activate().catch((err: any) => {
          console.log('err', err);
        });
    }}
  />

image

Disconnecting from the wallet

<button onClick={() => flashConnector.deactivate()}>Logout</button>

Fetching active state and account

import { hooks } from '../../connectors/flashConnector';
const { useAccount, useIsActive, chainId, useIsActivating } = hooks;
const active = useIsActive();
const account = useAccount();
const activating = useIsActivating();


// Use as

 {account && <p className="mt-2 text-green-500">account:{account}</p>}
 {chainId && <p className="mt-2 text-green-500">chainId:{chainId}</p>}
 {activating && <p className="mt-2 text-yellow-500">Connecting...</p>}

Local Development

  • Clone repo
    git clone https://github.com/mintmasterapp/hedera-react.git

  • Install top-level dependencies
    yarn

  • Install sub-dependencies
    yarn bootstrap

  • Build and watch for changes
    yarn start

hedera-react's People

Contributors

fnlog0 avatar aesthytik avatar

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.