• This repository has been archived on 23/Mar/2022
  • Stars
    star
    152
  • Rank 244,685 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple module for creating, managing and using Ethereum accounts in browser.

Synopsis

A simple module for creating, managing and using Ethereum accounts in browser.

Note, this module has not been upgraded. While it will still work with Ethereum dApps, I would recommend using this package instead: https://github.com/ConsenSys/eth-lightwallet.

About

This module allows the secure generation and management of Ethereum accounts in browser so that when browser stored accounts are being used by dApps, their outgoing transactions can be securly signed by the accounts stored in browser. All account data is stored in the browsers localStore and can be optionally encrypted with a passphrase using AES. If you're using Meteor.js, the Accounts object will be a reactive variable.

This module has been specifically designed as a transaction signer meant for use with the HookedWeb3Provider. See example below.

Please note that this module is still in Alpha. The security status of this module is still unknown and must still be vetted by trusted third-parties before production use.

Installation

Node.js

$ npm install ethereumjs-accounts

Meteor.js

$ meteor add silentcicero:ethereumjs-accounts

Usage

Require the NPM module or use the standalone browserified version where the 'Accounts' object is global.

var Accounts = require('ethereumjs-accounts');
var accounts = new Accounts({minPassphraseLength: 6}); // or new Accounts(..) if using dist.

// Generate a new account encrypted with a passphrase
var accountObject = accounts.new('myPassphrase');

/* console.log(accountsObject); // returns {accountObject}:
{
  "address": "0x169aab499b549eac087035e640d3f7d882ef5e2d",
  "encrypted": true,
  "locked": true,
  "hash": "342f636d174cc1caa49ce16e5b257877191b663e0af0271d2ea03ac7e139317d",
  "private": "U2FsdGVkX19ZrornRBIfl1IDdcj6S9YywY8EgOeOtLj2DHybM/CHL4Jl0jcwjT+36kDnjj+qEfUBu6J1mGQF/fNcD/TsAUgGUTEUEOsP1CKDvNHfLmWLIfxqnYHhHsG5",
  "public": "U2FsdGVkX19EaDNK52q7LEz3hL/VR3dYW5VcoP04tcVKNS0Q3JINpM4XzttRJCBtq4g22hNDrOR8RWyHuh3nPo0pRSe9r5AUfEiCLaMBAhI16kf2KqCA8ah4brkya9ZLECdIl0HDTMYfDASBnyNXd87qodt46U0vdRT3PppK+9hsyqP8yqm9kFcWqMHktqubBE937LIU0W22Rfw6cJRwIw=="
}
*/

// Get and decrypt an account stored in browser
var accountObject = accounts.get('0x169aab499b549eac087035e640d3f7d882ef5e2d', 'myPassphrase');

/* console.log(accountsObject); // returns {accountObject} unlocked:
{
  "address": "0x169aab499b549eac087035e640d3f7d882ef5e2d",
  "encrypted": true,
  "locked": false,
  "hash": "342f636d174cc1caa49ce16e5b257877191b663e0af0271d2ea03ac7e139317d",
  "private": "beab6210b7bbcc121c941832c9f944e7e755a836a23b23ee239b8f9a495c95f3",
  "public": "72f4b266d09f8b00a175a65e2448911c62680d18c9493a841f2b97ed61c187dad658a77ae9fdc61012a7064fdce0d2952cd0bdd04e00bc812e71efd8e0bc7e1e"
}
*/

// Return all accounts stored in browser
var account_list = accounts.get();

// Integrate with web3. See: https://github.com/ConsenSys/hooked-web3-provider
var provider = new HookedWeb3Provider({
  host: "http://localhost:8545",
  transaction_signer: accounts
});
web3.setProvider(provider);

API

Browserify

You may browserify ethereumjs-accounts, by installing the npm modules npm install and then running the browserify CMD below. Please refer to the examples to see how a standalone browserified version is setup and used.

$ browserify --s Accounts index.js -o dist/ethereumjs-accounts.js

Components

Security

This module uses the browser cyrptojs module to generate random alphanumeric characters. The security of this module as a safe source of random number generation is still not clear.

This module uses standardized AES encryption to encrypt the private and public keys of accounts before they are stored in browser storage. A hash is made that concats the public and private keys together in order to verify account decryption.

While localStore is known to be relatively secure, there is still a chance that browser extensions or third-party software could access the raw data. If a password is provided, this module will encrypt the private and public keys with AES before it is stored in the browsers local storage.

As stated previously, the security of this module is still unknown, and I do not in any way guarantee it to be secure or ready for production use.

Licence

Released under the MIT License, see LICENSE file.

More Repositories

1

ipfs-mini

A super tiny module for querying IPFS that works in the browser and node.
JavaScript
149
star
2

meteor-dapp-boilerplate

Boilerplate meteor dapp - starting point for meteor dapps using bootstrap
JavaScript
138
star
3

react-dapp-boilerplate

A highly standardized and optimized react dApp boilerplate.
JavaScript
122
star
4

ethdeploy

A complex deployment facility for Ethereum smart-contract development.
JavaScript
46
star
5

throw-down

life cycle hooks for pure DOM elements
JavaScript
40
star
6

ethereum-wallet-management

Pro-tips for Ethereum wallet management (Gitbook).
37
star
7

solint

A linting utility for Ethereum solidity smart-contracts
JavaScript
36
star
8

wafr

A super simple Solidity test harness for Ethereum smart-contracts.
JavaScript
30
star
9

ethjs-extras

All your dApp / App essentials for working with Ethereum.
JavaScript
18
star
10

yoyo-bootstrap

a yoyo version of the bootstrap visual framework
JavaScript
18
star
11

meteor-dapp-pricefeed

Meteor dapp for operating price feeds on Ethereum.
HTML
18
star
12

hyperapp-styled-components

styled-components for hyperapp in under 3kb
JavaScript
17
star
13

solidity-to-abi

Converts an Ethereum smart-contract solidity method interface string to a web3 ABI interface object.
JavaScript
8
star
14

meteor-solc

The solc package provides a Solidity compiler build plugin for the Meteor build tool.
JavaScript
8
star
15

ethnames

A micro-service which enables anyone to get an ENS name for free.
JavaScript
7
star
16

merklio

Merkl.io -- a free merkle-based notarization API micro-service for the Ethereum blockchain.
JavaScript
7
star
17

redux-contract

A higher order web3 contract decorator for dApps using redux
JavaScript
6
star
18

meteor-dapp-builder

A dApp builder.
JavaScript
5
star
19

meteoreth

A simple module for running meteor dApps with Ethereum
JavaScript
5
star
20

number-to-bn

Converts a number to a BN.js object, throw if invalid number.
JavaScript
5
star
21

web3-network-detective

A simple module to determine if your provider is on the mainnet or testnet.
JavaScript
5
star
22

csjs-loader

A csjs loader for webpack
JavaScript
4
star
23

meteor-package-ipfsapi

The IPFS api wrapped as a MeteorJS package.
JavaScript
4
star
24

metapool

Meta-transaction relay system based on a Single-Contract approve and EIP712 release model
JavaScript
4
star
25

yulit

Yul IDE for the Browser
JavaScript
3
star
26

Ethereum

Ethereum Projects
3
star
27

ensverify

An Ethereum name verification micro-service API that allows for a secondary source of proof for ENS name reduction (i.e. two-factor for ENS)
HTML
3
star
28

ethtoolbox

EthToolBox - Ethereum tools for the cool kids only.
JavaScript
3
star
29

strip-hex-prefix

A simple module to strip the hex prefix off a string, if a valid hex prefix is present.
JavaScript
3
star
30

language-yulp

Yul+ language support in Atom
2
star
31

LocalStore

A wrapper for localStorage, which will use chrome.storage if used in a chrome packaged app.
JavaScript
2
star
32

meteor-package-testrpc

Fast Ethereum RPC client for testing and development wrapped for Meteor =D
JavaScript
2
star
33

ethdeploy-cli

A CLI for the ethdeploy Ethereum smart-contract deployment staging utility.
JavaScript
2
star
34

ethdeploy-provider-zero-client

A zero client Web3 standard provider for ethdeploy
JavaScript
1
star
35

meteor-pocketbook

A mini-wallet for meteor dApps
JavaScript
1
star
36

meteor-solc-compiler

The solc compiler wrapped for MeteorJS
JavaScript
1
star
37

is-hex-prefixed

A simple is hex prefixed method to check if a string is hex prefixed.
JavaScript
1
star
38

buidler-boilerplate

Typescript / Buidler / Linked LIbrary and Workflow boilerplate for Ethereum Development
TypeScript
1
star