The TRON Developer Hub

Welcome to the TRON developer hub. You'll find comprehensive guides and documentation to help you start working with TRON as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

TRON’s signature algorithm is ECDSA, and the selected curve is SECP256K1.

From version 0.1.3, trident-java has implemented a wrapper class for SECP256K1.KeyPair in Core to facilitate the generation of private keys and the conversion of private keys to addresses. This classpath is: org.tron.trident.core.key.KeyPair;

  • Generate KeyPair
KeyPair keyPair = KeyPair.generate();
  • Import KeyPair with private key
KeyPair keyPair = new KeyPair("your private key");
  • Print Private & Public key
keyPair.toPrivateKey(); //String private key

keyPair.toPublicKey(); //String public key

🚧

Note

The public key does not equal to address.

  • Print Base58Check & Hex address
keyPair.toBase58CheckAddress();

keyPair.toHexAddress();
  • Use a specific public key to convert to byte[], Base58Check or Hex address
//the parent function, returns byte[]
KeyPair.publicKeyToAddress(SECP256K1.PublicKey pubKey); 
  
KeyPair.publicKeyToBase58CheckAddress(SECP256K1.PublicKey pubKey);
  
KeyPair.publicKeyToHexAddress(SECP256K1.PublicKey pubKey);
  • Sign
//this function returns the signature message in byte[]
KeyPair.signTransaction(byte[] txid, KeyPair keyPair);

Updated 2 months ago

KeyPair


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.