ethereum初探
簡介:
產生乙太幣地址
const crypto = require("crypto");
const ecdh = crypto.createECDH("secp256k1");
const sha3 = require("js-sha3");
var hash2 = crypto.randomBytes(32).toString("hex");
console.log("--------");
console.log("私鑰");
console.log(hash2.toString("hex")); //私鑰,64位十六進制數 //使用hash2.toString('hex')即可看到16進位字串
console.log("--------");
// ECDH和ECDSA產生公私鑰的方式都相同
var publickey = ecdh.setPrivateKey(hash2, "hex").getPublicKey("hex");
console.log("公鑰");
console.log(publickey); //公鑰(通過橢圓曲線算法可以從私鑰計算得到公鑰)
console.log("--------");
var sha3_256Key = sha3.keccak256(Buffer.from(publickey, "hex").slice(1)); // pubkey 轉為 buffer 後移除第一位
var address = sha3_256Key.substring(24, sha3_256Key.length); // 取後40字
var address = "0x" + address; //
console.log(address);常見名詞:
相關實用網站
Testnet
METAMASK
API Provider
線上錢包(類似線上版的MIST)
共識機制介紹
Block difficulty
Ethereum Gas 計算

獲取地址在特定時間的 Token 餘額
Last updated
