Closed ghost closed 3 years ago
Please check the detail info below: CreateAddress: https://developers.tron.network/reference#walletcreateaddress CreateAccount: https://developers.tron.network/reference#walletcreateaccount-1 generateAddress: https://developers.tron.network/reference-link/walletgenerateaddress
I need to know how can create new account and address with local full node
Please check the detail info below: CreateAddress: https://developers.tron.network/reference#walletcreateaddress CreateAccount: https://developers.tron.network/reference#walletcreateaccount-1 generateAddress: https://developers.tron.network/reference-link/walletgenerateaddress
These 3 API are also working on local fullnode API. just call these API on your fullnode to create a new account. Check detail guide from the link.
We will close this issue now, feel free to re-open it if you still face this issue.
@Benson0224 , The links that you have shared are just commands. There is no explanation. I think the question asked originally was never answered in this thread.
What is the relation between account and address ? It is it like BTC where you can one wallet with multiple addresses ? Please clarify on this
Secondly to create an account, it requires an existing account ? I mean I have a brand new full node fully synced ? How can I create an account to start with because as per the link you need to have an active account. Please clarify on this
Where are the account files stored as I need to delete the account once it is created
Please help !
Thanks for reaching out. check the answer below.
Thank you so much @Benson0224
Few quick questions out of your response,
I understand that the account could not be deleted from the chain. However, once you create an account using your full node, I would like to store private key and other data somewhere else. The full node sits on the public layer of our network and I don't want anything exposed. I understand that we can use some firewalling , but still I don't prefer to store any account data on my full node itself.
Why do we need an existing account to create new accounts ? Does it impact the newly created accounts somehow ? Just trying to understand the concept since we plan to create a new account and an address for each of our user.
Creating an account using a full node does not mean activating the account, it is the same as creating it via Library. the fullnode will return the address and private key to you, you can choose any place which is safe to keep it.
Regarding "Why do we need an existing account to create new accounts", here you may get misled by me. Creating one account ≠ Activating one Account. creating is free, but activating it has cost. you need one account to pay the cost.
The easiest way to activate one account is to transfer >0.1 TRX to the newly created account. try it on testnet, then you will understand how it works. thanks.
Thanks @Benson0224 for helping and clarifying, however, I think I may have not been able to convey my point clearly. I understand that creation and activation are just 2 separate functions.
Let me try to rephrase my question,
For example, if you create an account on BTC or ETH using your own full node, the account creation process will generate some files like UTC keyfile in the keystore directory or wallet.dat in case of BTC, on the full node. Likewise, when you create a TRON account using your full node, files are stored on which directory or path on the full node ?
See an example here, I am assuming its the account directory
root@tron-node-1:/trxdata/output-directory/database# ls
DelegatedResource account-asset-issue asset-issue-v2 common market_account pbft-sign-data storage-row tree-block-index
DelegatedResourceAccountIndex account-index balance-trace common-database market_order peers tmp utxo
IncrementalMerkleTree account-trace block contract market_pair_price_to_order properties trans votes
IncrementalMerkleVoucher accountTrie block-index delegation market_pair_to_price proposal trans-cache witness
abi accountid-index block_KDB exchange nodeId.properties recent-block transactionHistoryStore witness_schedule
account asset-issue code exchange-v2 nullifier section-bloom transactionRetStore zkProof
My apology. I did not get your point in the previous comments.
I would say how the accounts are stored depends on the client implementation, let me take Wallet-cli as an example. I would also suggest you use wallet-cli to create new accounts.
Wallet-Cli is an Interactive command-line wallet, so the newly created account will be directly printed to the terminal. Please refer to the below screenshot for detail.
Please find more info about wallet-cli here: https://github.com/tronprotocol/wallet-cli
One more info, the account creation API will directly return the new account info, pleaser refer to below screenshot for detail. thanks.
Please find more info about the API here: https://developers.tron.network/reference/walletgenerateaddress
Hope these 2 screenshots can help you. :)
@Benson0224 Thank you man 👍 , I will take it from here.
Best Regards,
@Benson0224 Sorry to bother you again, this is about tron's transaction structure which I am trying to understand.
I want to scan the blockchain and filter out transactions that contain addresses managed/hosted by us. So here is what I am doing,
I pass the block number to the API method GetTransactionInfoByBlockNum. This returns all the transactions in that block. For our understanding, I am just listing one transaction below. Now I am looking for the "From" and "To" address here which I don't seem to find as a tron address starts from a "T". What are these addresses in the log section? Where I can find a detailed description of all the fields?
Once again, I truly appreciate your support 👍
{
"log": [
{
"address": "2967c318a01cb50eb1f5bb99943b01012ad758f1",
"data": "000000000000000000000000000000000000000000000000028d2cbabaab1887",
"topics": [
"ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0000000000000000000000001e71ec9329412fc1c0e8feb6444dfa0ab28be078",
"0000000000000000000000002432bf90865a2ce329b7b31f1c026e2f5c030181"
]
},
{
"address": "1e71ec9329412fc1c0e8feb6444dfa0ab28be078",
"topics": [
"cd60aa75dea3072fbc07ae6d7d856b5dc5f4eee88854f5b4abf7b680ef8bc50f",
"000000000000000000000000059b75e27a02467c3faf234acf0dc8071e0d3f85",
"0000000000000000000000000000000000000000000000000000000008e9f3b0",
"000000000000000000000000000000000000000000000000028d2cbabaab1887"
]
},
{
"address": "1e71ec9329412fc1c0e8feb6444dfa0ab28be078",
"topics": [
"cc7244d3535e7639366f8c5211527112e01de3ec7449ee3a6e66b007f4065a70",
"000000000000000000000000059b75e27a02467c3faf234acf0dc8071e0d3f85",
"00000000000000000000000000000000000000000000000000017a84a0ce3be1",
"000000000000000000000000000000000000000000006cabcf658a95a2a390ce"
]
},
{
"address": "059b75e27a02467c3faf234acf0dc8071e0d3f85",
"data": "000000000000000000000000000000000000000000000000028d2cbabaab1887000000000000000000000000000000000000000000000000000000000006ddd0",
"topics": [
"3db78d97ccf1c1ebb5e17483bed7753c1ff6110f7fb3cbb7f7841b9a8ca67a0c",
"0000000000000000000000000000000000000000000000000000000000000000"
]
},
{
"address": "059b75e27a02467c3faf234acf0dc8071e0d3f85",
"data": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000002967c318a01cb50eb1f5bb99943b01012ad758f1",
"topics": [
"3f9e7bccea4c6198e1bd7984f72ce499496d32462515e94f700547087dadde08"
]
}
],
"fee": 17849440,
"blockNumber": 38494925,
"contractResult": [
"000000000000000000000000000000000000000000000000028d2cbabaab1887"
],
"blockTimeStamp": 1646030892000,
"receipt": {
"result": "SUCCESS",
"energy_fee": 17849440,
"energy_usage_total": 63748,
"net_usage": 448
},
"id": "9c746d14cf88180bf1bf75b4d7da94538ad530b4ebdf600b9cc9ccdec588b416",
"contract_address": "41059b75e27a02467c3faf234acf0dc8071e0d3f85"
},
First of all, addresses can have two formats, hex format or base58 format, these two formats can be converted into each other. base58 address always starts with "T".
For example this is a covert tool from tronscan : https://tronscan.org/#/tools/tron-convert-tool
There are many code examples on how to convert these 2 formats into each other on the internet. just pick one and parse all the data above. then you will see the base58 address.
one more comment, by default the API return is hex format, you can set the "Visible" parameter to true so the API will return base58 address: check this: https://api.trongrid.io/wallet/gettransactioninfobyblocknum?num=37253570&visible=true
Thank you so much @Benson0224 , that was helpful
Hi there, i think i have the same issue.. i just cant understand what im doing wrong here.. im using: https://tronprotocol.github.io/documentation-en/api/http/ for reff
after i created an address, i assume i need to create account.. because in the end i want to be able to check my balance and send funds out..
if i just use the address:
or if i use that tool:
Thanks!
import ecdsa
import base58
from Crypto.Hash import keccak
def generate_tron_address():
private_key = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1)
public_key = private_key.get_verifying_key().to_string("compressed")
keccak_hash = keccak.new(digest_bits=256)
keccak_hash.update(public_key)
public_key_hash = keccak_hash.digest()
return private_key.to_string().hex()
def hex_to_TRON_ADDR(key_string):
keybytes = bytes.fromhex(key_string)
sk = ecdsa.SigningKey.from_string(keybytes, curve=ecdsa.SECP256k1)
key = sk.get_verifying_key()
KEY = key.to_string()
Keccak = keccak.new(digest_bits=256)
Keccak.update(KEY)
pub_key = Keccak.digest()
primitive_addr = b'\x41' + pub_key[-20:]
addr = base58.b58encode_check(primitive_addr)
return addr.decode()
adr = []
for n in range(20):
private_key_hex = generate_tron_address()
address = hex_to_TRON_ADDR(private_key_hex)
adr.append((private_key_hex, address))
with open('tron_addresses.txt', 'a') as file:
for private_key, address in adr:
file.write(f'{private_key};{address}\n')
import ecdsa import base58 from Crypto.Hash import keccak def generate_tron_address(): private_key = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1) public_key = private_key.get_verifying_key().to_string("compressed") keccak_hash = keccak.new(digest_bits=256) keccak_hash.update(public_key) public_key_hash = keccak_hash.digest() return private_key.to_string().hex() def hex_to_TRON_ADDR(key_string): keybytes = bytes.fromhex(key_string) sk = ecdsa.SigningKey.from_string(keybytes, curve=ecdsa.SECP256k1) key = sk.get_verifying_key() KEY = key.to_string() Keccak = keccak.new(digest_bits=256) Keccak.update(KEY) pub_key = Keccak.digest() primitive_addr = b'\x41' + pub_key[-20:] addr = base58.b58encode_check(primitive_addr) return addr.decode() adr = [] for n in range(20): private_key_hex = generate_tron_address() address = hex_to_TRON_ADDR(private_key_hex) adr.append((private_key_hex, address)) with open('tron_addresses.txt', 'a') as file: for private_key, address in adr: file.write(f'{private_key};{address}\n')
Good, very intuitive example
My issue is I have a wallet that has Tron on it but I sent my tokens there but no bueno.
Trust wallet
1. What did you do?
Dear everyone, I am working on TRON for development of exchange platform. I am looking for the explanation about TRON account and address
2. What did you expect to see?
I want to create new account and derived addresses for each account. In case of BTC, we can create new wallet and generate new addresses for each wallet by using wallet name as a parameter. Eventually, all addresses represent one wallet. How can I do same thing as BTC in TRON ? What is the relation between createAccount, createAddress and generateAddress ?
3. What did you see instead?