初次在 Windows 10 安裝 Node.js 開發環境時,第一時間就發訊息給 Chang-Wu Chen 老師說:「還真的是超多坑的呀!」
若沒有踩過還真的會花很多時間在解 Bug,這一篇文章就是要你在坑上舖張墊子!
在出現的「新增使用者變數」視窗中,輸入下方數值:
%USERPROFILE%\.windows-build-tools 目錄內。> npm install --global --production windows-build-tools
%AppData%\npm\node_modules 內。> npm install --global ethereumjs-wallet
> npm install --global js-sha3
.\Homework-1\key.js 檔內撰寫如下程式碼:// npm-library
const Wallet = require('ethereumjs-wallet');
const keccak256 = require('js-sha3').keccak256;
// keypair
const wallet = Wallet.generate();
// privKey
const privKey = wallet.getPrivateKey();
console.log("privKey:", privKey);
// pubKey
const pubKey = wallet.getPublicKey();
console.log("pubKey:", pubKey);
// address
let address = wallet.getAddressString();
console.log("address:", address);
> cd %USERPROFILE%\go\src\github.com\oneleo\201809-Ethereum-DApp-Development-Homework
> node .\Homework-1\key.js
privKey: <Buffer 54 4c 7e 8c a9 6a 77 f9 da 4a 7a bb b3 b8 44 a7 45 e3 e3 51 50 2b 2e 0d 9a 15 a6 34 8b 41 43 33>
pubKey: <Buffer cd c5 f9 47 4d 76 91 0a 21 f2 5c 89 69 d2 72 bb 64 f2 eb e4 42 48 97 d9 3c 4a 5a d5 b7 83 db ad a1 d2 87 b0 3f d5 5b 00 b6 3b e7 b8 22 c7 f8 09 b4 31 ... >
address: 0x172051bda8a8d52afb906c333fa09a32d6ee3c9c
接下來我們就可以安心的在 Windows 10 中「安心」的開始開發與以太坊 EOA 或是智能合約介接的應用程式了呢!~
Donate ADA:
DdzFFzCqrhsup2Q4nnhKJJZ5BRuPkYUSPqDJn72t2dtHtVqsz5kQQmopMQR16Sv9qS5NC4w8Kv5P8XrDH2n2FD2akxtrntjc8hbgAmTz