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

How to use sendHexTransaction? #597

Open
zotakk4o opened this issue Jan 16, 2025 · 2 comments
Open

How to use sendHexTransaction? #597

zotakk4o opened this issue Jan 16, 2025 · 2 comments

Comments

@zotakk4o
Copy link

Hi, guys,
I would really like to figure out how to use the sendHexTransaction API but I can't figure out how to obtain the protobuf encoded transaction hex string after sign. Any Ideas or examples you can help with?

@Satan-web3
Copy link
Contributor

You can use txJsonToPb method to do it, for example:

const tx = await tronWeb.transactionBuilder.sendTrx(toAddress, 100*10e6);
const signedTx = await tronWeb.trx.sign(tx);
const pb = txJsonToPb(signedTx);
pb.addSignature(new Uint8Array(hexStr2byteArray(signedTx.signature[0])));
const result = await tronWeb.trx.broadcastHex(byteArray2hexStr(pb.serializeBinary()));

@zotakk4o
Copy link
Author

Thank you but the problem is that when I use privateKey: "01" in order to be able to generate the transaction data I get the error
Validate signature error: db91f809aa4acd967e860847c42224d35a8161caea843b2146a90ea952dafd80160d1e53d3ed9f98708d4df3761ab65ed6ba0950bbe130e997c4dfe740b201f71b is signed by TJKKhrZJuNn3FD7diRSjCtpCSydnSPp8Zd but it is not contained of permission.

I have no access to the private key so I cannot instantiate the tronweb lib with it.

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