提交 08db495f authored 作者: 崔大师's avatar 崔大师

update

上级 d2061c16
......@@ -65,6 +65,17 @@ const toAddress = (THAddress) => {
return web3.Iban.toAddress(THAddress).toString().toLowerCase()
}
const isAddress = (address) => {
return web3.isAddress(address).toString()
return web3.isAddress(address)
}
module.exports = { init, getTxHash, callContract, deployContract, ether, setVal, toIban, toAddress, isIban, isAddress };
\ No newline at end of file
module.exports = {
init,
getTxHash,
callContract,
deployContract,
ether,
setVal,
toIban,
toAddress,
isIban,
isAddress
};
\ No newline at end of file
#!/usr/bin/env node
const Web3 = require('thinkium-web3js');
const utils = require('ethereumjs-util');
const bip39 = require('bip39');
const HDWallet = require('ethereum-hdwallet')
const utils = require('ethereumjs-util');
const Web3 = require('thinkium-web3js');
const fs = require('fs');
const web3 = new Web3();
const rpxUrl = "http://rpctest.chainopen.cn"
web3.setProvider(new web3.providers.HttpProvider(rpxUrl));
const {mnemonic} = JSON.parse(fs.readFileSync("./config.json"));
const getPrivateKey = async (mnemonic,n) => {
const seed = await bip39.mnemonicToSeed(mnemonic.trim())
const hdwallet = HDWallet.fromSeed(seed)
const privateKey = hdwallet.derive('m/44\'/60\'/0\'/0/'+n).getPrivateKey();
const address = utils.privateToAddress((privateKey))
var account = web3.thk.GetAccount('1', '0x'+address.toString('hex'));
var balance = account.balance;
console.log("("+n+")"+"0x"+privateKey.toString('hex'),":",web3.Iban.toIban(("0x"+address.toString('hex'))).toString(),"("+web3.fromWei(balance,'ether')+" ether)")
const rpxUrl = "http://rpcproxy.thinkium.org"
const defaultChainId = "103";
const toIban = (address) => {
return web3.Iban.toIban(address).toString()
}
const getAccount = async(mnemonic,n) => {
const seed = await bip39.mnemonicToSeed(mnemonic.trim())
const hdwallet = HDWallet.fromSeed(seed)
const privateKey = hdwallet.derive('m/44\'/60\'/0\'/0/'+n).getPrivateKey()
const address = utils.privateToAddress(privateKey)
web3.setProvider(new web3.providers.HttpProvider(rpxUrl));
web3.thk.defaultPrivateKey = privateKey
web3.thk.defaultAddress = '0x' + address.toString('hex').toLowerCase()
web3.thk.defaultChainId = defaultChainId
var account = web3.thk.GetAccount(defaultChainId, '0x' + address.toString('hex'));
var balance = account.balance;
console.log("("+n+")"+"0x"+privateKey.toString('hex'),":","0x"+address.toString('hex'),web3.Iban.toIban(("0x"+address.toString('hex'))).toString(),"("+web3.fromWei(balance,'ether')+" ether)")
}
for(var i=0;i<10;i++){
getPrivateKey(mnemonic,i);
getAccount(mnemonic,i);
}
{
"mnemonic": "",
"mnemonic": "alley absorb wait alpha teach path pizza people home cloud announce kiwi",
"contractAddress": ""
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论