How to encode a signed transaction to submit the transaction in network?

I have tried using this link and got this response:


In docs:

" To sign a message using the response from this endpoint:

1)Decode the hex encoded string in the response to bytes.
2)Sign the bytes to create the signature.
3)Use that as the signature field in something like Ed25519Signature, which you then use to build a TransactionSignature. "

but I don’t know how to do these? any help is much appreciated.

 byte[] privateKeyBytes = Hex.decode(ACCOUNT_PRIVATE_KEY);
            AsymmetricKeyParameter privateKey = new Ed25519PrivateKeyParameters(privateKeyBytes, 0);

 byte[] responseBytes = Hex.decode(hexResponse.substring(2));
            // Create the signer
            Ed25519Signer signer = new Ed25519Signer();
            signer.init(true, privateKey);

            // Sign the message (hashRawTransaction)
//            byte[] message = hashRawTransaction(rawTransaction);
            byte[] message = responseBytes;
            signer.update(message, 0, message.length);
            byte[] signature = signer.generateSignature();

            // Convert the signature to a Hex string
            String hexSignature = Hex.toHexString(signature);

In the above code ACCOUNT_PRIVATE_KEY is a hex value I got from my martian wallet.


Check the node section

1 Like

You really want to start a class on coding now

1 Like

are you talking about this?