All Projects → HydroProtocol → hydro-sdk-wallets

HydroProtocol / hydro-sdk-wallets

Licence: Apache-2.0 license
Wallet connection integration for dApps. Provides a uniform interface to interact with multiple wallets.

Programming Languages

typescript
32286 projects
CSS
56736 projects

Projects that are alternatives of or similar to hydro-sdk-wallets

circles-myxogastria
Webapp and mobile client for Circles
Stars: ✭ 32 (+60%)
Mutual labels:  dapp
SkyGallery
Create galleries by uploading images and videos. Powered by Sia Skynet.
Stars: ✭ 23 (+15%)
Mutual labels:  dapp
hicetnunc
hicetnunc UI/UX
Stars: ✭ 802 (+3910%)
Mutual labels:  dapp
talisman-web
Unlock the Paraverse with Talisman Web. A Polkadot, Kusama & Parachain dashboard for the community.
Stars: ✭ 55 (+175%)
Mutual labels:  dapp
alcor-ui
Alcor Exchange | First self-listing onchain DEX for eosio tokens;
Stars: ✭ 103 (+415%)
Mutual labels:  dapp
builder
🍉 Build scenes for Decentraland
Stars: ✭ 141 (+605%)
Mutual labels:  dapp
atomex.client.wpf
Atomic swap exchange client for OS Windows
Stars: ✭ 15 (-25%)
Mutual labels:  cryptowallet
Rabby
The game-changing wallet for Ethereum and all EVM chains
Stars: ✭ 562 (+2710%)
Mutual labels:  dapp
Blockchain
Recently started working on Blockchain technologies. This repo contains material related to Blockchain technologies. My current focus on dAPP development using Hyperledger.
Stars: ✭ 21 (+5%)
Mutual labels:  dapp
thor-sync.electron
A browser that empowers DApps on VeChain
Stars: ✭ 52 (+160%)
Mutual labels:  dapp
scaffold-eth-typescript
Typescript version of Scaffold-Eth 🏗
Stars: ✭ 167 (+735%)
Mutual labels:  dapp
nextjs-dapp-starter-ts
A fullstack monorepo template to develop ethereum dapps
Stars: ✭ 228 (+1040%)
Mutual labels:  dapp
Chatangle
A free, decentralized, global chatroom, powered by the IOTA tangle
Stars: ✭ 16 (-20%)
Mutual labels:  dapp
ArianeeMaster
Smart contracts & tools for Arianee Protocol
Stars: ✭ 30 (+50%)
Mutual labels:  dapp
dtube
Decentralized video sharing & social media platform on Ethereum blockchain.
Stars: ✭ 70 (+250%)
Mutual labels:  dapp
qd-messages-ts
No ads, no tracking. Just a lightning fast peer-to-peer cross-platform messenger that doesn’t sell you out.
Stars: ✭ 22 (+10%)
Mutual labels:  dapp
zksync-dapp-checkout
zkCheckout — trustable permissionless DeFi payment gateway. Brand new zkSync dApp w/t all L2 perks: fast&cheap transfers / simple&quick withdrawal
Stars: ✭ 37 (+85%)
Mutual labels:  dapp
eth-plot
r/place inspired Dapp
Stars: ✭ 36 (+80%)
Mutual labels:  dapp
LunDAO
LunDAO 是一個鼓勵撰寫與 Ethereum 社群相關的中深度的中文文章,透過一個短期的實驗專案嘗試 DAO 可以如何進行社群治理以及回饋社群貢獻。
Stars: ✭ 50 (+150%)
Mutual labels:  dapp
create-react-native-dapp
Your next Ethereum application starts here. ⚛️ 💪 🦄
Stars: ✭ 410 (+1950%)
Mutual labels:  dapp

Introduction

Nearly every dapp needs to connect to a crypto wallet.There are many options such as metamask, ledger. Hydro sdk wallet makes it easier to integrate different kinds of wallets together, and give an uniform interfaces to interative with them.

Hydro SDK wallet also support browser local wallets. Secrets are saved in browser localstorage under your domain.

There is a default ui in this package. You can also implement another ui as you wish.

web-screen-shot

Support wallets:

Basic Usage Guide

This package requires React and Redux.

Step1: install npm package

npm i @gongddex/hydro-sdk-wallet

Step2: Wallet Reducer

The store should know how to handle actions coming from the wallet components. To enable this, we need to pass the WalletReducer to your store.

import { createStore, combineReducers } from "redux";
import { WalletReducer } from "@gongddex/hydro-sdk-wallet";

const rootReducer = combineReducers({
  // ...your other reducers here
  // you have to pass WalletReducer under 'WalletReducer' key
  WalletReducer
});

const store = createStore(rootReducer);

Step3: Wallet Component

To make the wallet logic work. We need to mount the Wallet and WalletButton components into your app. They should be mounted into Provider(see more details about Provider in react-redux). When the components is initialized, some monitors will start to work as well. They are monitoring the web3 wallet status(not installed, locking, account changed), ledger status(locked or not), and balances of all available addresses. You can config wallet through props. See more datials in the api section below.

import React from "react";
import { Provider } from "react-redux";
import { Wallet, WalletButton } from "@gongddex/hydro-sdk-wallet";
import { store } from "./store";
import "@gongddex/hydro-sdk-wallet/index.css";

class App extends React.Component {
  render() {
    return (
      <Provider store={store}>
        // ... your components
        <Wallet nodeUrl="https://ropsten.infura.io" />
        <WalletButton />
      </Provider>
    );
  }
}

Step4: Use Account

We can get the current selected account by using selector functions.

import React from "react";
import { connect } from "react-redux";

class App extends React.Component {
  signMessage = async () => {
    const { currentAccount } = this.props;
    const signature = await currentAccount.wallet.signPersonalMessage("test message");
    console.log(signature);
  };

  render() {
    return (
      <div>
        <button onClick={this.signMessage} />
      </div>
    );
  }
}
export default connect(state => {
  return {
    currentAccount: getSelectedAccount(state)
  };
})(App);

API

Wallet Component Props

Name Type Default Desc
nodeUrl String https://ropsten.infura.io Ethereum JSON RPC Endpoint.
defaultWalletType String EXTENSION default selected wallet type. Options are EXTENSION, Hydro_Wallet, WALLETCONNECT, Ledger.
translations Translations defaultTranslations i18n translations.
walletTypes Array defaultWalletTypes customized wallets.
menuOptions Option[] defaultMenuOptions customized wallet menu.
loadWalletActions Actions {} customized load wallet actions.
customLocalWallet WalletClass HydroWallet customized local wallet class.
hideLocalWallet Boolean false hide local wallet menu items.
unit String ETH balance unit.
decimals Number 18 balance decimals.
dcent DcentClass support D'CENT wallet, if provided, will show D'CENT option in dropdown menu.
appName String WalletLink prop.
appLogoUrl String WalletLink prop.
fortmaticApiKey String Fortmatic option, if provided, will show Fortmatic option in dropdown menu.
copyCallback Function alert("Copied to clipboard!") copy address callback.
email String TrezorConnect manifest param
host String TrezorConnect manifest param

Selectors

Methods to get data from redux store.

  • getAccount(state, accountID) Return the corresponding account
  • getSelectedAccount(state) Return the selected account
  • getAccounts(state) Return all available accounts

Action creators

These functions are redux action creators. You need to dispatch the result to store.

  • selectAccount(accountID, type) Change Selected Account
  • unlockBrowserWalletAccount(accountID, password) Unlock a browser local wallet
  • showWalletModal() Show the wallets modal
  • hideWalletModal() Hide the wallets modal

Account functions

When we get an account from redux store, we can call some functions of account.wallet object.

Send Transaction (eth_sendTransaction)

/**
 *  Draft transaction
 */
const tx = {
  from: "0xbc28ea04101f03ea7a94c1379bc3ab32e65e62d3",
  to: "0x0000000000000000000000000000000000000000",
  nonce: 1,
  gas: 100000,
  value: "0x0",
  data: "0x0"
};

/**
 *  Send transaction
 */
const txId = await wallet.sendTransaction(tx);

Sign Personal Message (personal_sign)

/**
 *  Draft Message Parameters
 */
const msgParams = [
  "HYDRO-AUTHENTICATION" //message
];

/**
 *  Sign personal message
 */
const signature = await wallet.signPersonalMessage(msgParams);

Send Custom Request

/**
 *  Draft Custom Request
 */
const customRequest = [
  "eth_getTransactionReceipt", //method
  ["0x452817c981809fb7fab716dc84114b97c9ad2542c72fb9ed2c64d79e1bddb937"] //params
];

/**
 *  Send Custom Request
 */
const customResponse = await wallet.sendCustomRequest(customRequest);

Try the examples

There are some examples projects. You can find commands to start these examples in package.json and source code in examples dir.

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].