How to decode XDR of the result_xdr in python with stellar_sdk
How to decode XDR of the result_xdr in python with stellar_sdk
Loading saved threads...
hotbit · External communityPost link
External question — Stellar Stack Exchange
Author: hotbit
Original post: https://stellar.stackexchange.com/questions/5734
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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}")```
Quote
Report
MNSH · External communityPost link
External answer — Stellar Stack Exchange
Author: MNSH
Original post: https://stellar.stackexchange.com/a/5789
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Was working recently working on a project and came across the same issue. While digging through the
stellar-sdk
code 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.
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]>
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External question — Stellar Stack Exchange Author: hotbit Source score (net votes, not local likes): 3 Original post: https://stellar.stackexchange.com/questions/5734 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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}")```
Checking account access…