TransactionEncoder { public static byte[] signMessage(RawTransaction rawTransaction, Credentials credentials) { byte[] encodedTransaction = encode(rawTransaction); Sign.SignatureData signatureData = Sign.signMessage( encodedTransaction, credentials.getEcKeyPair()); return encode(rawTransaction, signatureData); }  static byte[] signMessage(RawTransaction rawTransaction, Credentials credentials); static byte[] signMessage(
            RawTransaction rawTransaction, long chainId, Credentials credentials); static Sign.SignatureData createEip155SignatureData(
            Sign.SignatureData signatureData, long chainId); static byte[] encode(RawTransaction rawTransaction); static byte[] encode(RawTransaction rawTransaction, long chainId);  }
@Test public void testSignMessage() { byte[] signedMessage = TransactionEncoder.signMessage( createEtherTransaction(), SampleKeys.CREDENTIALS); String hexMessage = Numeric.toHexString(signedMessage); assertThat(hexMessage, is("0xf85580010a840add5355887fffffffffffffff80" + "1c" + "a046360b50498ddf5566551ce1ce69c46c565f1f478bb0ee680caf31fbc08ab727" + "a01b2f1432de16d110407d544f519fc91b84c8e16d3b6ec899592d486a94974cd0")); }
@Test public void testEip155Transaction() { Credentials credentials = Credentials.create( "0x4646464646464646464646464646464646464646464646464646464646464646"); assertThat(TransactionEncoder.signMessage( createEip155RawTransaction(), (byte) 1, credentials), is(Numeric.hexStringToByteArray( "0xf86c098504a817c800825208943535353535353535353535353535353535353535880" + "de0b6b3a76400008025a028ef61340bd939bc2195fe537567866003e1a15d" + "3c71ff63e1590620aa636276a067cbe9d8997f761aecb703304b3800ccf55" + "5c9f3dc64214b297fb1966a3b6d83"))); }