0

I am trying to get logs and innerInstruction from Raw instruction data.

The option to use the getTransaction RPC Method does not work, because the transaction I am trying to read is not yet in the blockchain. Its status is “pending”

In fact, I have already tried to call a simulation of this transaction. It seems like it should be possible to call a simulation without signatures. But no. The VersionedTransaction class expects private-keys, which it is clear that I do not have

Here is the transaction of which I need to get logs and innerInstruction

b'\x01\x1e+\xe9\xcd\x85\x1c\x8b\xeaQ\x04=\x9b\x0cN\xc2\xba\\ly\x8d\xc1\x15Sn\xe5xc\xbb\x0cf\xf4\xb4r\x9b\x82\x94\xd2\xa6\x8eN\x9f\x9b\n\x1b~&WF\xe8MKk\x02K[eU_(\xe3\x8dlT\r\x01\x00\t\x0e\xc5\xed\xbb\xaa\x8a\xf5\xa7\x0c\xb1\xebkW\xa3\xdf4\xaf\x94\xcd\xdd1[9\xc0o\xf5\xf8v\x82\x8af\x1aZX\x96\xe6\x9aq\x1bnI\x02@\xe34\xd1\xe6\x8dth\x85\xfcJ\xb2+d\xb4\xd8/\x19\xdcD%\xba_vL\xdf3x[]EW2\x81\x8a\x1aa\xf9\xcdE\x9b\xfeDx\xf2\xef\xecO\x94\xaay\x89"\xce\x02\xa5\xb4\x7f\xe6\xb3(Y\x8fcf\xc9\x00\xa4\xc3\x07\xf5\xac\xeb\xb0\x8f.u\x9fy_\xc8\x9e\x17\n\xda\xdc\xee\xad\x11\xe6\xa4\xfc)D\xa4\xfa\x82Q\xbe\xf8\x15Bn\x1b\xfb(\xc6\xb6dfw`|j\xd9\xf5f\xa6F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01V\xe0\xf6\x93fZ\xcfD\xdb\x15h\xbf\x17[\xaaQ\x89\xcb\x97\xf5\xd2\xff;e]+\xb6\xfdm\x18\xb0\x03\x06Fo\xe5!\x172\xff\xec\xad\xbar\xc3\x9b\xe7\xbc\x8c\xe5\xbb\xc5\xf7\x12k,C\x9b:@\x00\x00\x00\x06\xa7\xd5\x17\x19,\\Q!\x8c\xc9L=J\xf1\x7fX\xda\xee\x08\x9b\xa1\xfdD\xe3\xdb\xd9\x8a\x00\x00\x00\x00\x06\xdd\xf6\xe1\xd7e\xa1\x93\xd9\xcb\xe1F\xce\xeby\xac\x1c\xb4\x85\xed_[7\x91:\x8c\xf5\x85~\xff\x00\xa9:\x86^i\xee\x0fT\x80\xca\xbc\xf6cW\xe4\xdc/\x18\xd5\x8dE\xc1\xeat\x89\xfb7#\xd9y<r\xa6n\xc3\xe2\x89\x1c{\xf2u7?\xcb\xb3\xa9\xd7 \xb4S\xb4\xf1\x87\xd0\x146\x98\n\xd9\xc3t!\x07\xc6\x8f\x8c\x97%\x8fN$\x89\xf1\xbb=\x10)\x14\x8e\r\x83\x0bZ\x13\x99\xda\xff\x10\x84\x04\x8e{\xd8\xdb\xe9\xf8Y\xac\xf16\xeb\x01\xfc\x1cN\x88=#\xc8\xb5\x84J\xb5\x9a7\xf6j\xddW\xc5\xe9\xac;S\xe0Y\xd3\\d\xec}$5\xa1Zv<os\x88k{3c&kzD\xa2\x92i!qNz\xef\xe95\x8a\xac\x12\x04\x0c\x07\x00\x01\x00\x0b\x05\t\x08\x00\x06\x0c\n\x04\x0b\x02\x03\x01\x00\x05\t\x08\r\x06\x1af\x06=\x12\x01\xda\xeb\xea\x000\xef}\xba\x02\x00\x00\x00\xe1\xf5\x05\x00\x00\x00\x00\x00\x00\x07\x00\t\x03@\r\x03\x00\x00\x00\x00\x00\x07\x00\x05\x02@\r\x03\x00'

Also, here's an example of the code I used to get the transaction simulation, but it doesn't work

raw_transaction = b'here raw data which is upper'
client = Client(f'https://mainnet.helius-rpc.com/?api-key={os.getenv("HELIUS_API_KEY")}')
transaction = Transaction.deserialize(raw_transaction)
blockhash_ = client.get_latest_blockhash()
message = MessageV0.try_compile(
    instructions=transaction.instructions,
    payer=transaction.fee_payer,
    recent_blockhash=blockhash_.value.blockhash,
    address_lookup_table_accounts=[]
)
versioned_transaction = VersionedTransaction(message=message, keypairs=[Keypair()])
resp = client.simulate_transaction(versioned_transaction)
print(resp.to_json())

I will be grateful for any help :)

1 Answer 1

1

When using the getTransaction RPC call, be sure to select the appropriate commitment level. For example, in testing, processed might be suitable since it's more likely to allow immediate retrieval. You could also try waiting a few seconds before fetching again if it doesn’t appear right away. For more on commitment levels, see this guide.

I'm not familiar with Python specifically, but the calls may be similar to those in solana/web3.js (version 1.x).

Calling simulate_transaction will return the same response as the RPC HTTP endpoint’s simulateTransaction method. See the documentation.

The response object is SimulateTransactionResp (reference), so the transaction simulation logs should be accessible via the value field.

To avoid requiring all signatures, set the sig_verify parameter to False (which I understand is False by default...)

def simulate_transaction(
    self,
    txn: Union[Transaction, VersionedTransaction],
    sig_verify: bool = False,
    commitment: Optional[Commitment] = None,
) -> SimulateTransactionResp:

When calling simulate, using VersionedTransaction(message=message, keypairs=[]) with empty keypairs may work then?

2
  • thanks for your answer, but versionedTransaction return error when keypairs is empty or None. Also simulate_transaction cannot get txn as Transaction. It's also return error. Only VersionedTransaction and it requieres keypairs, here is the main problem
    – lil
    Commented Nov 12 at 18:27
  • Rather than using VersionedTransaction(message=message, keypairs=[]) try using VersionedTransaction.populate(message = message, signatures=[]) with empty signatures. More info at github.com/kevinheavey/solders/blob/…
    – Jon C
    Commented Nov 14 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.