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

update

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