I am creating a transaction. When I am submitting the transaction to the blockchain it is giving an error. I will post the code below. Could anyone tell me where I am going wrong?

from stellar_base.keypair import Keypair
from stellar_base.asset import Asset
from stellar_base.operation import Payment
from stellar_base.transaction import Transaction
from stellar_base.transaction_envelope import TransactionEnvelope as Te
from stellar_base.memo import TextMemo
from stellar_base.horizon import horizon_testnet, horizon_livenet

amount = '100'

Alice = Keypair.from_seed(alice_seed)

horizon = horizon_testnet() # horizon = horizon_livenet() for LIVENET

asset = Asset("XLM") 
# create op 
op = Payment({
    # 'source' : Alice.address().decode(),
    'destination': bob_address,
    'asset': asset,
    'amount': amount
# create a memo
msg = TextMemo('Buy yourself a beer !')

# get sequence of Alice
# Python 2
# sequence = horizon.account(Alice.address()).get('sequence')
# Python 3
sequence = horizon.account(Alice.address().decode('utf-8')).get('sequence')

# construct Tx
tx = Transaction(
    source = Alice.address().decode('utf-8'),
    opts = {
        'sequence': sequence,
        # 'timeBounds': [],
        'memo': msg,
        'fee': 100,
        'operations': [

# build envelope
envelope = Te(tx=tx, opts={"network_id": "TESTNET"}) # envelope = Te(tx=tx, opts={"network_id": "PUBLIC"}) for LIVENET
# sign 
# submit
xdr = envelope.xdr()
response = horizon.submit(xdr)


     {'type': 'https://stellar.org/horizon-errors/transaction_failed', 'title': 'Transaction Failed', 'status': 400, 
        'detail': 'The transaction failed when submitted to the stellar network. The `extras.result_codes` field on this response contains further details. 
     Descriptions of each code can be found at: https://www.stellar.org/developers/learn/concepts/list-of-operations.html', 'extras': {'envelope_xdr': 'AAAAAPR3ubJjpkTChNWRQL2Wz+zwE+QK7ajEern8JCTqFlQMAAAAZABrCz0AAAAJAAAAAAAAAAEAAAAVQnV5IHlvdXJzZWxmIGEgYmVlciAhAAAAAAAAAQAAAAAAAAABAAAAAI1Dva4U01cL+IUv6hvL3Lz6PO3KSkrKsn98ZKBfcETbAAAAAAAAAAA7msoAAAAAAAAAAAHqFlQMAAAAQCXbz+tU5jVsOVmPZqekaz9T3LGbenfMdg4Ql2MKyIcsOyS81WtbvLqnTbcz8b0AP3JRhId/vfHUuyAcnzFxGw0=', 
{'transaction': 'tx_failed',
 'operations': ['op_bad_auth']}, 
'result_xdr': 'AAAAAAAAAGT/////AAAAAf////8AAAAA'}}

2 Answers 2


The issue is you signed the transaction using ALICE. it need to be alice_seed. Alice is a key pair where alice_seed is the private key


I don't see Alice source Address in your above code as you have commented that in the transaction envelope, can you add that and then try to send the payment.

Something you need to know :-

  • The error op_bad_auth usually occurs when you send payment either using incorrect private key or sending an asset you are not authorized to send.

  • Check Bob's account is funded with some tokens using testnet.

Try to create your transaction exactly using stellar labs transaction builder.


Now you are getting op_bad_auth and that can be possible because of above reasons, so try it at stellar labs and you will know.

  • I removed the comment and tried and even Bob's account is also funded and have a balance but the same error occurs. Alice_seed = 'SCQUFZIFKMF3CYXAYKPKBQZRF33O3YKJMQXL63PVW7O66GBQOTVKR3A5' Alice_addr = 'GD2HPONSMOTEJQUE2WIUBPMWZ7WPAE7EBLW2RRD2XH6CIJHKCZKAYMZ3' Bob_addr = 'GCGUHPNOCTJVOC7YQUX6UG6L3S6PUPHNZJFEVSVSP56GJIC7OBCNXHUA'
    – merklexy
    Commented Jun 26, 2018 at 10:38
  • Did you try this exact transaction on stellar labs as well ?The reason I am asking this question is because you are getting an error message so basically your implementation is correct but you are either putting incorrect key or basic error is there which is not related to implementation.
    – Peter
    Commented Jun 26, 2018 at 10:40
  • I tried the exact transaction in stellar labs as well with the keys I gave it to you. Even the same error in stellar labs also. I am really confused. Could you try it once in stellar labs with the above keys?
    – merklexy
    Commented Jun 26, 2018 at 10:46

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.