Wallets

是否可以使用遠端區塊鏈執行乙太坊錢包?

  • April 10, 2016

要在手機或上網本等小型電腦上執行乙太坊錢包,擁有一個輕客戶端會很有用,它可能連接到託管的完整乙太坊節點。這目前可能嗎?

是的,您可以使用連接到遠端節點web3.js

添加 web3

  1. npm:$ npm install web3
  2. 涼亭:$ bower install web3
  3. 流星:$meteor add ethereum:web3
  4. 香草:連結dist./web3.min.js

然後你需要創建一個 web3 實例,設置一個提供者。為確保在迷霧中不會覆蓋已設置的提供程序,請首先檢查 web3 是否可用:

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"));

創建錢包地址

安裝ETH-lightwallet

npm install ETH-lightwallet

創建錢包的範常式式碼。

// 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! 
});

引用自:https://ethereum.stackexchange.com/questions/2780