Skip to main content

I posted my own answer here in case someone else has the question. Web3j provides a ECKeyPair as util to process key and address conversion. Please see codes below:

        String privateKey = "{your private key}";
        Credentials cs = Credentials.create(privateKey);
        
        String privateKey = cs.getEcKeyPair().getPrivateKey().toString(16);
        String publicKey = cs.getEcKeyPair().getPublicKey().toString(16);
        String addr = cs.getAddress();
        
        System.out.println("Private key: " + privateKey);
        System.out.println("Public key: " + publicKey);
        System.out.println("Address: " + addr);
String privateKey = "{your private key}";
Credentials cs = Credentials.create(privateKey);

String privateKey = cs.getEcKeyPair().getPrivateKey().toString(16);
String publicKey = cs.getEcKeyPair().getPublicKey().toString(16);
String addr = cs.getAddress();

System.out.println("Private key: " + privateKey);
System.out.println("Public key: " + publicKey);
System.out.println("Address: " + addr);

I posted my own answer here in case someone else has the question. Web3j provides a ECKeyPair as util to process key and address conversion. Please see codes below:

        String privateKey = "{your private key}";
        Credentials cs = Credentials.create(privateKey);
        
        String privateKey = cs.getEcKeyPair().getPrivateKey().toString(16);
        String publicKey = cs.getEcKeyPair().getPublicKey().toString(16);
        String addr = cs.getAddress();
        
        System.out.println("Private key: " + privateKey);
        System.out.println("Public key: " + publicKey);
        System.out.println("Address: " + addr);

I posted my own answer here in case someone else has the question. Web3j provides a ECKeyPair as util to process key and address conversion. Please see codes below:

String privateKey = "{your private key}";
Credentials cs = Credentials.create(privateKey);

String privateKey = cs.getEcKeyPair().getPrivateKey().toString(16);
String publicKey = cs.getEcKeyPair().getPublicKey().toString(16);
String addr = cs.getAddress();

System.out.println("Private key: " + privateKey);
System.out.println("Public key: " + publicKey);
System.out.println("Address: " + addr);
Source Link
Frank Kong
  • 700
  • 1
  • 6
  • 16

I posted my own answer here in case someone else has the question. Web3j provides a ECKeyPair as util to process key and address conversion. Please see codes below:

        String privateKey = "{your private key}";
        Credentials cs = Credentials.create(privateKey);
        
        String privateKey = cs.getEcKeyPair().getPrivateKey().toString(16);
        String publicKey = cs.getEcKeyPair().getPublicKey().toString(16);
        String addr = cs.getAddress();
        
        System.out.println("Private key: " + privateKey);
        System.out.println("Public key: " + publicKey);
        System.out.println("Address: " + addr);