5

I am trying to decode a serialized Solana raw transaction the issue I am facing is I couldn't find any files nor code related to this on the Solana web3 JS library could anyone please advice ?

I was going through this file

https://github.com/solana-labs/solana-web3.js/blob/master/src/transaction.ts

thanks

Dominique
  • 16,450
  • 15
  • 56
  • 112
f4r4
  • 563
  • 8
  • 19

2 Answers2

2

This is how instructions are encoded. As for instruction data, the question is if the serialized data is self-describing or not. If it isn't you will have to view the code of the program you are sending the instruction to, since: Programs are free to specify how information is encoded into the instruction data byte array.

  • Is it possible to view the code of every program? And if so how? For example the Magic Eden program – Tomvkgames Jun 16 '22 at 07:57
  • I don't think so, maybe if you try to decompile the byte code to opcodes for all the languages that Solana programs can be written in and try to make sense of which language the program is in and then understanding the opcodes (very time consuming). On Ethereum it is more straight forward since all programs (smart contracts) are written in Solidity. Check out how etherscan does it https://etherscan.io/bytecode-decompiler . – jakethefinn Jun 17 '22 at 08:15
1

To decode an unsigned transaction The txBufferFromHex variable should contain

{ 01 + empty 64 byte signature (64 bytes of 00) + unsigned transaction } 

then the from method will out put decoded instruction set

const tx = Transaction.from(txBufferFromHex);
f4r4
  • 563
  • 8
  • 19
  • How do this work on Phantom Wallet to decode the transaction passed to it? I'm stuck on decoding that message, maybe you can contribute to the answer: https://stackoverflow.com/questions/70253380/decode-a-solana-raw-transaction – mursang Dec 07 '21 at 10:05