Code Monkey home page Code Monkey logo

usedapp's Introduction

useDapp

CI Npm package version Discord

Ethereum ๐Ÿค React

Framework for rapid Dapp development.
Simple. Robust. Extendable. Testable.

About

Introduces great features:

  • ๐Ÿ—๏ธ React hooks - Uses React hooks as your primary building ingredient
  • ๐Ÿš… Auto refresh - Refreshes on a new block, wallet change or network change
  • ๐Ÿ›’ Multicall - Combines multiple blockchain calls into a single multicall

Combines the best practices:

  • ๐Ÿ”ง Modern stack - Employs ethers.js, multicall & waffle
  • ๐Ÿ“š Extendability - Extends easily with custom hooks
  • ๐Ÿ’ก Testability - Simple integration tests for UI and blockchain

Example

import { Mainnet } from '@usedapp/core/modal/chain/ethereum'
import { useEthers, useEtherBalance } from '@usedapp/core'

const config = {
  readOnlyChainId: Mainnet.chainId,
  readOnlyUrls: {
    [Mainnet.chainId]: 'https://mainnet.infura.io/v3/62687d1a985d4508b2b7a24827551934',
  },
}

ReactDOM.render(
  <DAppProvider config={config}>
    <App />
  </DAppProvider>,
  document.getElementById('root')
)

const STAKING_CONTRACT = '0x00000000219ab540356cBB839Cbe05303d7705Fa'

export function App() {
  const { activateBrowserWallet, deactivate, account } = useEthers()
  const userBalance = useEtherBalance(account)
  const stakingBalance = useEtherBalance(STAKING_CONTRACT)

  return (
    <div>
      {!account && <button onClick={activateBrowserWallet}> Connect </button>}
      {account && <button onClick={deactivate}> Disconnect </button>}
      {stakingBalance && <p>ETH2 staking balance: {formatEther(stakingBalance)} ETH </p>}
      {account && <p>Account: {account}</p>}
      {userBalance && <p>Ether balance: {formatEther(userBalance)} ETH </p>}
    </div>
  )
}

See application here.

Documentation

For detailed feature walkthrough checkout documentation.

Contributing

Contributions are always welcome, no matter how large or small. Before contributing, please read the code of conduct and contribution policy.

Before you issue pull request:

  • Make sure all tests pass.
  • Make sure linter passes.
  • Make sure you have test coverage for any new features.

To install dependencies type:

npm i -g pnpm
pnpm install

To build project:

yarn build

To run tests type:

yarn test

To run linter type:

yarn lint

License

useDapp is released under the MIT License.

usedapp's People

Contributors

clumsyvlad avatar devanoneth avatar dmaretskyi avatar doubleotheven avatar dylankilkenny avatar gasolin avatar github-actions[bot] avatar hubertnastaly avatar itsshadowl avatar jaywelsh avatar justynabroniszewska avatar lcamargof avatar m00nbeans avatar marcin-trust avatar marekkirejczyk avatar miziet avatar mj426382 avatar nezouse avatar perski6 avatar quagliero avatar rzadp avatar sz-piotr avatar szymx95 avatar t4t5 avatar truefi-bot avatar truefibot avatar tt-marek avatar tylerether avatar vanruch avatar yivlad 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.