9

To run the Ethereum Wallet on a small computer like a Phone or a Netbook it would useful to have a light client, possibly that connects to a hosted full Ethereum node. Is this currently possible?

5

Yes it is possible you can connect to a remote node using web3.js

Adding web3

  1. npm: $ npm install web3
  2. bower: $ bower install web3
  3. meteor: $meteor add ethereum:web3
  4. vanilla: link the dist./web3.min.js

Then you need to create a web3 instance, setting a provider. To make sure you don't overwrite the already set provider when in mist, check first if the web3 is available:

if(typeof web3 !== 'undefined')
  web3 = new Web3(web3.currentProvider);
else
  // set the provider you want from Web3.providers
  web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

Create a Wallet Address

Install ETH-lightwallet

npm install ETH-lightwallet

sample code to create a wallet.

// generate a new BIP32 12-word seed 
var secretSeed = lightwallet.keystore.generateRandomSeed();

// the seed is stored encrypted by a user-defined password 
var password = prompt('Enter password for encryption', 'password');
lightwallet.keystore.deriveKeyFromPassword(password, function (err, pwDerivedKey) {

var ks = new lightwallet.keystore(secretSeed, pwDerivedKey);

// generate five new address/private key pairs 
// the corresponding private keys are also encrypted 
ks.generateNewAddress(pwDerivedKey, 5);
var addr = ks.getAddresses();

// Create a custom passwordProvider to prompt the user to enter their 
// password whenever the hooked web3 provider issues a sendTransaction 
// call. 
ks.passwordProvider = function (callback) {
  var pw = prompt("Please enter password", "Password");
  callback(null, pw);
};

// Now set ks as transaction_signer in the hooked web3 provider 
// and you can start using web3 using the keys/addresses in ks! 
});
  • 1
    And how? :-) ... even though it's no good style to ask yes/no questions, I would expect finding more than a 'yes' as an answer if I stuble upon this thread coming from a search engine or similar. – Waqar Lim Apr 8 '16 at 12:08
  • 1
    @5chdn there you go.. :) – niksmac Apr 10 '16 at 1:32
7

There is a light client protocol page on the Ethereum wiki. It describes the general concept, and suggests some implementation details.

A light client can be viewed as a client that downloads block headers by default, and verifies only a small portion of what needs to be verified, using a distributed hash table as a database for trie nodes in place of its local hard drive.

The C++ and Go clients are still implementing a light client feature. There are github issues tracking the cpp-ethereum light client and the go-ethereum light client.

3

Currently the only way you can achieve this is by connecting to Geth using the Json RPC api, there are different libraries which simplify the RPC and general transactions with contracts like web3.js the main javascript library or Nethereum.Web3 for .Net.

On Nethereum you can find an example of a cross platform "wallet" which uses this method of communication. Nethereum Wallet. Or the very simple Android Maker Sample

With web3.js you should be able to achieve the same using Cordova with Ionic.

  • does NEthereum support Geth's light mode already, Juan? – knocte May 7 '17 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.