🤢
🤢
🤢
🤢
Tron
搜索文档…
Generate Address Offline

Python

1
import ecdsa
2
import base58
3
import ecdsa
4
import random
5
​
6
from Crypto.Hash import keccak
7
​
8
​
9
def keccak256(data):
10
hasher = keccak.new(digest_bits=256)
11
hasher.update(data)
12
return hasher.digest()
13
​
14
​
15
def get_signing_key(raw_priv):
16
return ecdsa.SigningKey.from_string(raw_priv, curve=ecdsa.SECP256k1)
17
​
18
​
19
def verifying_key_to_addr(key):
20
pub_key = key.to_string()
21
primitive_addr = b'\x41' + keccak256(pub_key)[-20:]
22
# 0 (zero), O (capital o), I (capital i) and l (lower case L)
23
addr = base58.b58encode_check(primitive_addr)
24
return addr
25
​
26
​
27
while True:
28
raw = bytes(random.sample(range(0, 256), 32))
29
# raw = bytes.fromhex('a0a7acc6256c3..........b9d7ec23e0e01598d152')
30
key = get_signing_key(raw)
31
addr = verifying_key_to_addr(key.get_verifying_key()).decode()
32
print('Address: ', addr)
33
print('Address(hex):', base58.b58decode_check(addr.encode()).hex())
34
print('Public Key: ', key.get_verifying_key().to_string().hex())
35
print('Private Key: ', raw.hex())
36
​
37
break
38
​
Copied!

Rust

PHP

JavaScript

1
const TronWeb = require('tronweb');
2
​
3
console.log(TronWeb.utils.accounts.generateAccount());
Copied!
​

Java

​
复制链接