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(
source=receiver_address,
opts={
'sequence': sequence,
'memo': msg,
'operations': [
op,
],
},
)
# 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"})
envelope.sign(receiving_account)
xdr_envelope = envelope.xdr()
# Submit the signed transaction to Horizon server.
response = horizon.submit(xdr_envelope)
print(response)
if 'result_xdr' in response:
return True
else:
print('Things go Fishy while opr_change_trust')
return False