solana-labs / solana-web3.js

Solana JavaScript SDK
https://solana-labs.github.io/solana-web3.js
MIT License
2.08k stars 838 forks source link

decode tx instructions #1001

Closed roccomuso closed 1 year ago

roccomuso commented 3 years ago

does the lib support decoding instructions to know what type of program is that? like the tx explorer does, like detecting from the programId what kind of instruction that. I found this: https://github.com/solana-labs/explorer/blob/master/src/utils/tx.ts

Moreover, why are these deprecated? https://github.com/solana-labs/solana-web3.js/blob/master/src/transaction.js#L621-L646

jstarry commented 3 years ago

does the lib support decoding instructions to know what type of program is that?

Sort of. You can request "parsed" transactions which, if supported, will decode the instruction for you. Right now we just have support for built in programs (system, vote, stake, etc) and a few SPL programs (token, memo). You can call connection.getParsedConfirmedTransaction which will call the getConfirmedTransaction RPC API with the "jsonParsed" encoding parameter.

Moreover, why are these deprecated? https://github.com/solana-labs/solana-web3.js/blob/master/src/transaction.js#L621-L646

Heh, those should be removed at this point. They are deprecated because those methods should only exist on transaction instructions. Those APIs were added a long time ago before transactions consisted of multiple instructions

github-actions[bot] commented 1 year ago

Hi @roccomuso,

Thanks for your question!

We want to make sure to keep signal strong in the GitHub issue tracker – to make sure that it remains the best place to track issues that affect the development of the Solana JavaScript SDK itself.

Questions like yours deserve a purpose-built Q&A forum. Unless there exists evidence that this is a bug with the Solana JavaScript SDK itself, please post your question to the Solana Stack Exchange using this link: https://solana.stackexchange.com/questions/ask


This automated message is a result of having added the ‘question’ tag.

github-actions[bot] commented 1 year ago

Because there has been no activity on this issue for 7 days since it was closed, it has been automatically locked. Please open a new issue if it requires a follow up.