ABP
ABP

Reputation: 744

Tron TRC20 HD Wallet for generate multi deposit address for one account

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.

Upvotes: 5

Views: 4082

Answers (2)

Nick
Nick

Reputation: 304

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.

Upvotes: 1

Zeraldo Zua Zangue
Zeraldo Zua Zangue

Reputation: 21

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

Upvotes: 2

Related Questions