Skip to content

bearby-wallet/bearby-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bearby react web3 wrapper

Allows react to interact with the bearby wallet.

Introduction

The react web3 module of bearby wallet.

Quick Start

In your project:

yarn add @hicaru/bearby-react # or npm install @hicaru/bearby-react

The first step is to wrap you App or any React subtree with the BearbyProvider

import { BearbyProvider } from '@hicaru/bearby-react';

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

In any React child of the provider, one can use the useBearby hook in order to access the state and methods.

import { useBearby, BearbyProvider } from '@hicaru/bearby-react';

function App() {
    const { connected, enabled, wallet, massa, contract, base58, net, period } = useBearby();

    return (
        <div>
            <p>
                connected:({String(connected)})
            </p>
            <p>
                period:({String(period)})
            </p>
            <p>
                enabled:({String(enabled)})
            </p>
            <p>
                base58:({String(base58)})
            </p>
            <p>
                network:({String(net)})
            </p>
            <button onClick={() => wallet.connect()}>
                connect
            </button>
        </div>
    );
}

About

A simple Context provider and consumer hook in order to provide a simple API for interacting with bearby in the browser

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published