Tracking the unspent singleton coin

I am trying to grok singleton concept in Chia, and I understand that the launcher_id can be used as a permanent address.

If I give the launcher_id to Alice, Alice could get the unspent singleton coin by looking for a coin with an odd amount having parent_info == launcher_id, and if it’s spent, then look for another coin with an odd amount having parent_info == last_spent_singleton_coin_id and so on until you get the first unspent coin.

Let’s say we create and spend singleton coins:

L -> Eve -> S1 -> S2 -> S3 -> S4

In this case, S4 is the unspent singleton coin that we want to acquire from blockchain. That means Alice will have to access blockchain 5 times (n) to get S4.

Is there a more efficient way?

You can use coin hints

Whenever you recreate the singleton, pass through the singleton launcher_id as hint. Then you can fetch it via “get by puzzlehash” RPC.

1 Like

Thanks! That exactly solves the problem. But I think you mean get_coin_records_by_hint and not get_coin_records_by_puzzle_hash.

1 Like