Skip to content

TrueFiEng/useDApp

master
Switch branches/tags
Code

Latest commit

* Add own implementation

* Create local-storage-implementation.md

* Fix lint

* Update packages/core/src/constants/type/Config.ts

Co-authored-by: Przemyslaw Rzad <przemyslaw.rzad@trusttoken.com>

* Add localStorageObject

* Add local storage improvement

* Update packages/core/src/constants/type/Config.ts

Co-authored-by: Przemyslaw Rzad <przemyslaw.rzad@trusttoken.com>

* Remove neccessary localStorageItem

* Add own implementation

* Fix lint

* Create local-storage-implementation.md

* Update packages/core/src/constants/type/Config.ts

Co-authored-by: Przemyslaw Rzad <przemyslaw.rzad@trusttoken.com>

* Add localStorageObject

* Add local storage improvement

* Update packages/core/src/constants/type/Config.ts

Co-authored-by: Przemyslaw Rzad <przemyslaw.rzad@trusttoken.com>

* Remove neccessary localStorageItem

* Some changes

* Some changes

* Linting

* Remove unnecessary if statement

* Some changes

* Update packages/core/src/hooks/useLocalStorage.ts

* Remove unnecessary if statement

* Add custom localStorage

* Remove unnecessary if statement

* Refactor LocalStorage class

Co-authored-by: mj426382 <mateusz.jandula@trusttoken.com>
Co-authored-by: Przemyslaw Rzad <przemyslaw.rzad@trusttoken.com>
Co-authored-by: Jakub SieczczyΕ„ski <j.sieczczynski@gmail.com>
e89b3d6 3

Git stats

Files

Permalink
Failed to load latest commit information.

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.