How to properly set 'Value' in a ManageData operation on Stellar-SDK in Python?

How to properly set 'Value' in a ManageData operation on Stellar-SDK in Python?

Manage alerts

Loading saved threads...

Pickinanameainteasy · External communityPost link
External question — Stellar Stack Exchange Author: Pickinanameainteasy Original post: https://stellar.stackexchange.com/questions/5711 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'm trying to set up a managedata operation. I added the following to my transaction: .append_manage_data_op(data_name="Hello", data_value="World") However, it doesn't go through. Apparently the correct syntax is data_value='Union[Keypair, str]'. So I tried this: .append_manage_data_op(data_name="Hello", data_value='Union[keypair, "World"]') But it still doesn't work. Note in the above code 'keypair' is a variable representing 'Keypair.from_secret(my_secret). What is Union and do I need to replace it with something else to make the transaction go through?
Quote
Report
ire_and_curses · External communityPost link
External answer — Stellar Stack Exchange Author: ire_and_curses Original post: https://stellar.stackexchange.com/a/5732 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. It looks like you need to take a step back and fill in some Python basics before proceeding. Based on the error you posted in the comments, you aren't using the Server class correctly. You need to create an instance of the Server class and then call the load_account method on that instance. See e.g. the example here from the Python Stellar SDK docs: server = Server(horizon_url="https://horizon-testnet.stellar.org") source = Keypair.from_secret("SBFZCHU5645DOKRWYBXVOXY2ELGJKFRX6VGGPRYUWHQ7PMXXJNDZFMKD") destination = Keypair.random() source_account = server.load_account(account_id=source.public_key) To understand the more general concept, check out https://stackoverflow.com/a/625098/143804 for a discussion of self in Python.
Quote
Report

Post Reply

Checking account access…