sign
và ecRecover
, ví dụ:
const Web3 = require('web3'); const fs = require('fs'); const Strings = require('./strings'); let provider = new Web3.providers.HttpProvider("http://localhost:8545/"); let web3 = new Web3(provider); web3.eth.defaultAccount = "0x3c31b4b9d6c24bad29498f99aaa6914231362c7f"; // contract address not account address var registerJson = '{' + ' "username": "dzung",' + ' "password": "123456",' + ' "email:": "dung@youngmonkeys.org"' + '}'; var registerHex = Strings.stringToHex(registerJson); web3.eth.personal.sign(registerHex, web3.eth.defaultAccount, "123") .then((signed) => { console.log("signed register: ", signed) web3.eth.personal.ecRecover(registerHex, signed) .then((address => console.log("the address: ", address))); });