3

I created an account with:

TronWeb.utils.accounts.generateAccount()

Now I want to create child address of above account for every users.

When users deposit to these addresses, I want to manage balance from main account and transfer to another users all balances with one transaction.

Like HD Wallet on Bitcoin or ADA Cardano and etc.

ABP
  • 692
  • 4
  • 21

2 Answers2

0

Before these Mnemonic functionality in tronweb was not available in packge npm version 4.4.0. It was recently released. Usage examples:

const TronWeb = require('tronweb');

console.log(TronWeb.fromMnemonic('patch left empty genuine rain normal syrup yellow consider moon stock denial',"m/44'/195'/0'/0/3"));

exit:

{
  privateKey: '781C49346BC8F7BCE6FF54FCD6D1A486E5F01238207124FC57DBFBDD91F325B6',
  publicKey: '0421274E7431BFEE7428A42E71DB43D97773813CC50CE9FCA6D82CC72AED36618A1A3BF81B56967D888586F8240DE2078F798CB653AB1C7B681D2C2E82EA2B5A14',
  address: {
    base58: 'TFaC1WRiabPe8PU7NEFtPuPuLoHmtUSEkK',
    hex: '413D765BFA4E0D353931737D80393C6AD78F459EB7'
  }
}

Visit: https://developers.tron.network/reference/frommnemonic

  • Thanks. I want to use like BTC. can I? for example: I want to transfer all addresses balance to main wallet. without any fee for per address to move to main wallet address. – ABP Oct 31 '22 at 11:02
  • You intend to use the same bitcoin, more on the trc20 network. Right? – Zeraldo Zua Zangue Nov 01 '22 at 12:47
0

As Tron transaction has no inputs and outputs concept you need to collect coins from all addresses manually creating a transaction for each address to send coin from it to desired target address.

And you need to pay fee for each such transaction. Actually for bitcoin you usually pay the same atomic fees because adding each output to bitcoin transaction costs according to memory added to transaction.

If you want it to be a single transaction you can try to design a smart contract accumulating coins from all your addresses and sending them to some target address.

Nick
  • 144
  • 1
  • 4