Greetings Stellar StackExchange community,

I would kindly require your assistance as I am having hard time figuring out how to get the incoming transaction amount value, and what would be the most appropriate way to do it for my personal account.

Currently I have function which return transactions, but this ones include memo, fees, hash, xdr_envelope and so on, however not amount. What I need for my "app" is TX HASH, MEMO, VALUE and PAGING token as I am storing them into database.

def get_transactions(self):
        data = server.transactions().for_account(account_id=self.public_key).include_failed(False).call()
        for tx in data['_embedded']['records']:
            te = TransactionEnvelope.from_xdr(tx['envelope_xdr'], Network.TESTNET_NETWORK_PASSPHRASE)

While pretty printing each TransactionEnvelope, I am getting back object but not values.

I have been as well looking at the post How to decode XDR of the result_xdr however due to the new package for python I "hit the wall".

I tried as well use Payments For Account while amount is returned however there is no Memo.

 data = server.payments().for_account(account_id=self.public_key).call()

Could you please help me resolve the issues I am having?

thank you for your time, answer and assistance in advance, and hope to get response soon.

best regards


2 Answers 2


A stellar transaction consists of one or more operations such as payment, createAccount, setOptions.

I'm not familiar with python-sdk but I think like in other sdk's the transaction object should also have a operations method or property which should deliver all related operations. You have to iterate through the operations of a given transaction (for op in tx['operations']), figure out if it is a payment operation (if op['type'] == 'payment') and then access asset and amount on that object (op['asset'], op['amount'])


At first, I recommend you read this article, which describes the composition of a transaction.

Hope this example helps.

from stellar_sdk import TransactionEnvelope, Network, TextMemo, IdMemo, HashMemo, ReturnHashMemo, Payment


te = TransactionEnvelope.from_xdr(envelope_xdr, Network.TESTNET_NETWORK_PASSPHRASE)
tx_hash = te.hash_hex()
print(f"hash: {tx_hash}")
raw_memo = te.transaction.memo
memo = None
if isinstance(raw_memo, TextMemo):
    memo = raw_memo.memo_text
if isinstance(raw_memo, IdMemo):
    memo = raw_memo.memo_id
if isinstance(raw_memo, HashMemo):
    memo = raw_memo.memo_hash
if isinstance(raw_memo, ReturnHashMemo):
    memo = raw_memo.memo_return
print(f"memo: {memo}")
operations = te.transaction.operations
for op in operations:
    # You can check other types of operations here.
    # You can find list of operations here: https://stellar-sdk.readthedocs.io/en/latest/api.html#operation
    if isinstance(op, Payment):
        amount = op.amount
        asset_code = op.asset.code
        asset_issuer = op.asset.issuer
        destination = op.destination
        source = op.source or te.transaction.source.public_key
        print(f"{source} send {amount} {asset_code}({asset_issuer}) to {destination}")
  • Thank you for response
    – Animus
    Mar 12, 2020 at 18:45

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.