How to curried for standard transaction

(SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle solution)

; "assert" is a macro that wraps repeated instances of "if"
; usage: (assert A0 A1 ... An R)
; all of A0, A1, ... An must evaluate to non-null, or an exception is raised
; return the last item (if we get that far)

(defmacro assert items
    (if (r items)
        (list if (f items) (c assert (r items)) (q . (x)))
        (f items)

(include condition_codes.clvm)
(include sha256tree.clvm)

; "is_hidden_puzzle_correct" returns true iff the hidden puzzle is correctly encoded

(defun-inline is_hidden_puzzle_correct (SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle)
          (pubkey_for_exp (sha256 original_public_key (sha256tree delegated_puzzle)))

; "possibly_prepend_aggsig" is the main entry point

(defun-inline possibly_prepend_aggsig (SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle conditions)
  (if original_public_key
          (is_hidden_puzzle_correct SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle)
      (c (list AGG_SIG_ME SYNTHETIC_PUBLIC_KEY (sha256tree delegated_puzzle)) conditions)

; main entry point

    SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle
    (a delegated_puzzle solution))


how to use this puzzle to spend my coin,How to curried for SYNTHETIC_PUBLIC_KEY

If you use python, you can provide your public key and get the puzzle by calling this function puzzle_for_public_key_and_hidden_puzzle_hash.

The puzzle can then be provided to your CoinSpend and SpendBundle.

alice_puzzle = puzzle_for_public_key_and_hidden_puzzle_hash(, DEFAULT_HIDDEN_PUZZLE_HASH

spend_bundle = SpendBundle(
            alice.puzzle, # p2_delegated_puzzle_or_hidden_puzzle

I have some example of how the standard coin can be spent. also has a good note and lot of functions you can use for your scenario (e.g., get the synthetic_pk or solutions).

tks, this is for hidden puzzle.How to curried in delegated puzzle.and what comes from? If i want to curried by cdv tools, What should I do? is from simulator wallet, but you can just get pk: G1Element from hex string like this:

pk: G1Element = G1Element.from_bytes(bytes.fromhex("a4d7da9a1c5210352e4487abc45cc09ca7e523630740e208087c4eb5f0c7ea85819c7affae1b1c846feabf49b071ad1d"))`

To curry the puzzle via cdv, you have to compile your delegated puzzle first.
Here is some short example:

main.clsp (outer)

(mod (PUZZLE solution)
    (a PUZZLE solution)

addition.clsp (inner)

mod (x y) (+ x y))

compile main.clsp and addition.clsp

❯ cdv clsp build main.clsp                                                     
Beginning compilation of main.clsp...
...Compilation finished

❯ cdv clsp disassemble main.clsp.hex
(a 2 5)
❯ cdv clsp build addition.clsp
Beginning compilation of addition.clsp...
...Compilation finished

❯ cdv clsp disassemble addition.clsp.hex
(+ 2 5)

curry in and run the puzzle

(+ 2 5) is the compiled addition.clsp mod.

❯ cdv clsp curry main.clsp.hex -a '(+ 2 5)'                                    
(a (q 2 2 5) (c (q 16 2 5) 1))

❯ brun '(a (q 2 2 5) (c (q 16 2 5) 1))' '((100 12))'

I have found curried guite this in chialisp doc. but if i want to curried delegated puzzle for a coin in my wallet what can I do?How to get SYNTHETIC_PUBLIC_KEY by cdv or chia command

You can use cdv inspect keys --help.

❯ cdv inspect keys --synthetic --public-key a4d7da9a1c5210352e4487abc45cc09ca7e523630740e208087c4eb5f0c7ea85819c7affae1b1c846feabf49b071ad1d --hidden-puzhash 711d6c4e32c92e53179b199484cf8c897542bc57f2b22582799f9
Public Key: ab29ecd3b1425ee081a371ac4b819fd0b1f94de7517cb51937e268e1ebda958ce19bf0b7d3eebbf26ba9c5283f7df6a5
Fingerprint: 2432166656
HD Path: m

ab29ecd3b1425ee081a371ac4b819fd0b1f94de7517cb51937e268e1ebda958ce19bf0b7d3eebbf26ba9c5283f7df6a5 is a synthetic_public_key.

Thanks,How is the PK obtained here associated with coin in my wallet.
How to generate the puzzle and solution of specified coin

The public key you get is SYNTHETIC_PUBLIC_KEY, so you can curry in and get a standard coin puzzle, so, basically, pk + hidden puzzle -> coin puzzle -> puzzle hash.

But if you have a specific coin with coin_id and puzzle_hash, you probably need to grab all of your available public keys from your wallet db, generate the puzzle, and check which one generates the puzzle hash matched your coin.

For solution, please look at solution_for_conditions in which is similar to how it’s generated here.