Help with classes chia classes in python

Hi guys, I’m having some real trouble with something I believe should be quite easy. I’d like to create an instance of the Spend Bundle class, and fill in the appropriate variables - something like this:

spend = SpendBundle([coin2spend, Issue_Program, p2_puzzle_solution],[aggregatedsig])

However, I just can’t get it to work for the life of me! - this is the kind of data I have, but I can’t seem to get it in the right format:

spend_bundle = {"aggregated_signature": "c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coin_spends": [{"coin": coinrecords_first_unspent,"puzzle_reveal": Issue_Program, "solution": p2_puzzle_solution} ]}

Can anyone help? It’s driving me around the bend! I’ve tried everything I can think of, and tried to dig down into the code, but its not particularly clear. I’ve also tried doing this like creating a json object then doing SpendBundle.from_json_dict(myspendbundleJsonobject)

  • P.s. I know I can push this json with the wallet, but can anyone help me actually create an instance of the spendbundle class? at the moment I have each of the variables in a string type.



The spend bundle should be something like this:

coin_spend_1 = CoinSpend(
            coin, # Coin
            puzzle_reveal, # Program
            solution, # Program

coin_spend_2 = ...

sig: G2Element = AugSchemeMPL.sign(...)

# or for empty signature
# sig = G2Element() 

spend_bundle: SpendBundle = SpendBundle(
    sig, # G2Element

Here is some working spend bundle sample via simulator.

Hi Dan, please take a look at this guide: Tips for using the Chia Developers forum

There’s a section on how to use markdown to format code blocks.

Thanks! This was super helpful!