2

I want to retrieve transaction details from the response message. The same could be possible queering a horizon, but it seems an unnecessary waste of resources to send additional requests to the horizon if the information is already received.

A very exact question has been asked 3 years ago How to decode XDR of the result_xdr but the solution is based on the old stellar_base library.

I assume I should use from_xdr() function, but unsure which object to attach to.

response = server.submit_transaction(transaction)
tx_result = ???.from_xdr(response["result_xdr"])
print(f"xdr_result: {tx_result}")```

1 Answer 1

0

Was working recently working on a project and came across the same issue. While digging through the stellar-sdkcode I found out that it has an xdr module which you can use to decode information from the result_xdr

Let's work with the following TransactionResult for as an example.enter image description here

To obtain the offerId we can do this:

from stellar_sdk.xdr import TransactionResult

tx_result = TransactionResult.from_xdr(response['result_xdr'])
offer_id = tx_result.result.results[0].tr.manage_sell_offer_result.success.offers_claimed[0].offer_id

print(offer_id)
<Int64 [int64=359738]>

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.