I am working on Stellar Python SDK after a year. When I ran my old script I got the error:

TypeError: __init__() got an unexpected keyword argument 'opts'

The code given below:

from stellar_base.asset import Asset
from stellar_base.horizon import horizon_testnet
from stellar_base.keypair import Keypair
from stellar_base.memo import TextMemo
from stellar_base.operation import ChangeTrust, Payment
from stellar_base.transaction import Transaction
from stellar_base.transaction_envelope import TransactionEnvelope as Te
def opr_change_trust(asset_object, receiver_address, receiver_seed, horizon):
    # Operation Object
    op = ChangeTrust({
        'source': receiver_address,
        'asset': asset_object,
        'limit': '5000'

    print('Establishing trust-line for the account {}. Please wait!!'.format(receiver_address))

    # Getting the next sequence of the address
    sequence = horizon.account(receiver_address).get('sequence')

    # Create Text Memo
    msg = TextMemo('Change Trust Operation')

    # construct Tx
    tx = Transaction(
            'sequence': sequence,
            'memo': msg,
            'operations': [
    # xdr = tx.xdr()
    # deccoded_xdr = tx.to_xdr_object()
    # print(deccoded_xdr)

    # Get reference of receiving account
    receiving_account = Keypair.from_seed(receiver_seed)
    # build envelope
    envelope = Te(tx=tx, opts={"network_id": "TESTNET"})

    xdr_envelope = envelope.xdr()
    # Submit the signed transaction to Horizon server.
    response = horizon.submit(xdr_envelope)

    if 'result_xdr' in response:
        return True
        print('Things go Fishy while opr_change_trust')
        return False

1 Answer 1


Documentation is available here: https://stellar-base.readthedocs.io/en/latest/api.html#transaction

The transaction object is constructed like so:

Transaction(source, sequence, time_bounds=None, memo=None, fee=None, operations=None)

Passing in opts as a list seems to be causing the issue.

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.