Gathering detailed insights and metrics for eth-sdk-wallet
Gathering detailed insights and metrics for eth-sdk-wallet
Gathering detailed insights and metrics for eth-sdk-wallet
Gathering detailed insights and metrics for eth-sdk-wallet
npm install eth-sdk-wallet
Typescript
Module System
TypeScript (94.77%)
CSS (5.23%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Apache-2.0 License
2 Stars
220 Commits
2 Forks
1 Watchers
16 Branches
4 Contributors
Updated on Oct 26, 2023
Latest Version
0.1.8
Package Id
eth-sdk-wallet@0.1.8
Unpacked Size
348.55 kB
Size
71.58 kB
File Count
75
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
17
5
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.
This package requires React
and Redux
.
npm i eth-sdk-wallet
The store should know how to handle actions coming from the wallet components. To enable this, we need to pass the EthWalletReducer
to your store.
1import { createStore, combineReducers } from "redux"; 2import { EthWalletReducer } from "eth-sdk-wallet"; 3 4const rootReducer = combineReducers({ 5 // ...your other reducers here 6 // you have to pass EthWalletReducer under 'EthWalletReducer' key 7 EthWalletReducer 8}); 9 10const store = createStore(rootReducer);
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.
1import React from "react"; 2import { Provider } from "react-redux"; 3import { Wallet, WalletButton } from "eth-sdk-wallet"; 4import { store } from "./store"; 5import "eth-sdk-wallet/index.css"; 6 7class App extends React.Component { 8 render() { 9 return ( 10 <Provider store={store}> 11 // ... your components 12 <Wallet nodeUrl="https://ropsten.infura.io" /> 13 <WalletButton /> 14 </Provider> 15 ); 16 } 17}
We can get the current selected account by using selector functions.
1import React from "react"; 2import { connect } from "react-redux"; 3 4class App extends React.Component { 5 signMessage = async () => { 6 const { currentAccount } = this.props; 7 const signature = await currentAccount.wallet.signPersonalMessage("test message"); 8 console.log(signature); 9 }; 10 11 render() { 12 return ( 13 <div> 14 <button onClick={this.signMessage} /> 15 </div> 16 ); 17 } 18} 19export default connect(state => { 20 return { 21 currentAccount: getSelectedAccount(state) 22 }; 23})(App);
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. |
String | TrezorConnect manifest param | ||
host | String | TrezorConnect manifest param |
Methods to get data from redux store.
getAccount(state, accountID)
Return the corresponding accountgetSelectedAccount(state)
Return the selected accountgetAccounts(state)
Return all available accountsThese functions are redux action creators. You need to dispatch the result to store.
selectAccount(accountID, type)
Change Selected AccountunlockBrowserWalletAccount(accountID, password)
Unlock a browser local walletshowWalletModal()
Show the wallets modalhideWalletModal()
Hide the wallets modalWhen we get an account from redux store, we can call some functions of account.wallet
object.
1/** 2 * Draft transaction 3 */ 4const tx = { 5 from: "0xbc28ea04101f03ea7a94c1379bc3ab32e65e62d3", 6 to: "0x0000000000000000000000000000000000000000", 7 nonce: 1, 8 gas: 100000, 9 value: "0x0", 10 data: "0x0" 11}; 12 13/** 14 * Send transaction 15 */ 16const txId = await wallet.sendTransaction(tx);
1/** 2 * Draft Message Parameters 3 */ 4const msgParams = [ 5 "HYDRO-AUTHENTICATION" //message 6]; 7 8/** 9 * Sign personal message 10 */ 11const signature = await wallet.signPersonalMessage(msgParams);
1/** 2 * Draft Custom Request 3 */ 4const customRequest = [ 5 "eth_getTransactionReceipt", //method 6 ["0x452817c981809fb7fab716dc84114b97c9ad2542c72fb9ed2c64d79e1bddb937"] //params 7]; 8 9/** 10 * Send Custom Request 11 */ 12const customResponse = await wallet.sendCustomRequest(customRequest);
There are some examples projects. You can find commands to start these examples in package.json and source code in examples dir.
This project is licensed under the Apache 2.0 License - see the LICENSE file for details
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
project is archived
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
78 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More