Call the delegated or hidden puzzle using only native Chia wallet?

I have some previous exposure to Lisp and am broadly comfortable with the layout of coins and puzzles, from the perspective of executing in brun, etc. I’m struggling a bit with the mental leap to how a delegated or hidden puzzle might be used in a wallet. For example, is there some way for me to trigger the hidden puzzles using a native transaction in the light wallet? Or, can it only be done using a spend bundle constructed programmatically and broadcast to the chain?

In a similar vein, once a puzzle hash is known to the chain, is it possible to convert that puzzlehash to an xch address and use it as the trigger for a smart contract, by sending “dumb” XCH to it?

2 Likes

The way our current wallet works is that it always uses the delegated puzzle spend path. It signs a program that looks like this:

(q . (list CONDITION CONDITION ...))

It’s very basic functionality. The delegated puzzle is a concept known as graftroot, where any functionality is allowed as long as it’s signed for by the pubkey in the puzzle. The hidden puzzle is a concept known as taproot, where execution paths are committed to in the puzzle, but do not need to be revealed unless they are being spent.

There’s no way to use the hidden puzzle functionality in the standard chia wallet, but in the future, it could be good for things like atomic swaps where you can prove to a party that you have the ability to use the hidden puzzle to claw back the funds and so it’s pointless for them not to pay you. In the honest scenario, this just looks like a standard transaction on chain, but the existence of a hidden puzzle was crucial to it going through.

2 Likes

Thanks, @quexington . On the second part about the address corresponding to a puzzle hash, what type of functionality is enabled by having puzzlehashes be renderable as addresses?

From 4.4 Addresses | Chia Documentation, I understand that is a thing, but does sending funds to a puzzlehash address somehow cause that coin to be protected by that puzzle?

Right, addresses are just an encoded puzzle hash. Think about sending the coin to a new owner rather than “triggering” anything. It’s also important to remember that when something is a type of asset besides Chia (for example a CAT), that is also part of a puzzle hash and CATs only allow themselves to be spent if their parent was a CAT. You can send to whatever address/puzzlehash you’d like, but that does not guarantee that you will be able to spend the coin at that puzzle hash because they will sometimes assert things that will not be true if you just send to them. Also, some puzzles morph outgoing puzzle hashes when you spend them and the address that you see the new funds arrive at may not be the same address you specified. For this reason, make sure you’re only sending to addresses that are marked as “receive addresses” in some sort of client.

2 Likes

I’m specifically interested in taking advantage of this puzzlehash as address concept. So, if I send to the puzzlehash’s address, the coin is now owned by that puzzlehash? So, a spend bundle including a solution to that puzzle would then be required to move those funds?

I was curious if it were possible to mint a multiple issuance CAT simply by sending XCH to a puzzlehash and then return the CAT to the sending wallet. If I’m understanding correctly, you could do that non-atomically in two blocks by having a process watch the chain for changes and then trigger the send back.

Just as a thought exercise, I was trying to figure out if it were possible to build this type of functionality with Chia’s primitives and tooling using Chialisp, or if other tooling like scripts with RPC hooks were required.

The coin is now owned by whoever can spend that puzzle hash yet. So yes, you could have a puzzle that for example, can be spent by anyone, but the only thing it could do is send a CAT back to the address from which it came. Then you hash that puzzle, encode to an address, provide the address to people, and if you have a script watching the blockchain, you can detect those spends and trigger the send back.

1 Like