1.0.1 • Published 2 years ago

react-bittensor v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-bittensor

A React library for state management of the subtensor blockchain

NPM JavaScript Style Guide

Install

npm install --save react-bittensor

OR

yarn add react-bittensor

Usage

In your App.js or _app.js (next.js) add the Bittensor Provider

import { BittensorProvider } from 'react-bittensor';


const MyApp = (props) => {
  const { Component, pageProps } = props;

  return (
    <BittensorProvider>
      <Component {...pageProps} />
    </BittensorProvider>
  );
};

then call Bittensor from anywhere.

import { useBittensor } from 'react-bittensor'


function MyComponent() {

  const { 
    api, // API object that has a websocket to subtensor
    difficulty, // number type, current registration difficulty
    total_issuance, // number type, total issuance
    total_stake, // number type, total stake
    n, // number type, total machines in active set
    get_balance, // function, takes (api, ADDRESS)
    create_coldkey, //function takes no args, returns {mnemonic: mnemonic, pair: pair}
    create_hotkey, //function takes no args, returns {mnemonic: mnemonic, pair: pair}
  } = useBittensor();

  ...

}

License

MIT © noburu-org