Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make signed transaction offline #100

Open
fereshteh-jvz opened this issue Aug 13, 2023 · 1 comment
Open

make signed transaction offline #100

fereshteh-jvz opened this issue Aug 13, 2023 · 1 comment

Comments

@fereshteh-jvz
Copy link

How to make signed transaction offline? Right now I can make signed transaction with apiWrapper. But in my case I cannot connect to nodes and I need to create and sign the transaction offline so I can broadcast it with https://api.trongrid.io/wallet/broadcasttransaction api. Thanks in advance for your help

@lxcmyf
Copy link

lxcmyf commented Aug 14, 2023

@fereshteh-jvz
Please refer to trident sdk, https://github.com/tronprotocol/trident/blob/master/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java

public Chain.Transaction signTransaction(Response.TransactionExtention txnExt, KeyPair keyPair) {
        byte[] txid = txnExt.getTxid().toByteArray();
        byte[] signature = KeyPair.signTransaction(txid, keyPair);
        Chain.Transaction signedTxn = txnExt.getTransaction().toBuilder().addSignature(ByteString.copyFrom(signature)).build();
        return signedTxn;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants