CAT - sender address - HOW?

Hello all, who can help me with a problem bugging me for days now. I am using the dkackman’s chia-dotnet that is basically a C# RPC interface lib.
I want to recover the SENDER WALLET ADDRESS in a CAT transaction using RPC.

I have tried:
private static async Task GetAddressFromPuzzle(TransactionRecord transaction)
{
//Open the full_node endpoint to get the return address
EndpointInfo full_node_endpoint = Config.Open().GetEndpoint(“full_node”);
using HttpRpcClient full_node_rpcClient = new HttpRpcClient(full_node_endpoint);
FullNodeProxy full_nodeProxy = new FullNodeProxy(full_node_rpcClient, “chia_originservice”);

	//Get the parent coin from the full node
        string parentcoin = transaction.Additions.First().ParentCoinInfo;
        CoinRecord coinRecord = await full_nodeProxy.GetCoinRecordByName(parentcoin);
	
	//convers puzzlehash to address
        Bech32M bech32M = new Bech32M();
        string? address = bech32M.PuzzleHashToAddress(coinRecord.Coin.PuzzleHash);

        return address;
  }

This code works perfectly for a Coin (Chia) but gives me another wallet address for a CAT (if I try send a CAT to this address does not return in the sender wallet).

Can someone explain what is different with CAT’s? What I am missing?

Thanks in advance.

The puzzle hash you get is the CAT puzzle hash.

To get the wallet address, you have to get the wallet puzzle hash which is the hash of the inner puzzle wrapped by the CAT puzzle.

So once you get the parent coin (sender), you can find its parent coin spend and get the wallet puzzle hash from the memo of the CREATE_COIN condition.

The chia-dev-tools command cdv clsp cat_puzzle_hash can help you verify if you get the correct wallet puzzle hash.

1 Like

i have tried to implement the way you said but I can’t make it work.
Do you have a real example on how to do it.

I am missing something. I have tried all RCP calls that I am aware of but nothing.

There is no designated RPC call for that, so there are a couple steps to do.

In a Coin Set Model, information is kept in the blockchain in coins themselves and/or in a coin spend.

First method: Find parent’s parent and run its puzzle and solution to get CREATE_COIN condition.

  1. Find a parent coin id of the parent of the CAT coin using get_coin_records_by_parent_ids

  2. Once you get the parent’s parent coin id and its spent block height (the confirmed_block_index of the parent should be the same as the spent_block_index of its parent’s parent) , you can find the CoinSpend using get_puzzle_and_solution.

  3. Once you have the CoinSpend, you can run the puzzle_reveal with the solution and get the list of conditions which should include (CREATE_COIN <outer_ph> amount (<inner_ph>)) and you can get the CAT wallet address from the inner_ph.

Second method: Because CAT curries in the inner puzzle, we can uncurry parent’s puzzle and find the inner puzzle hash from the 3rd uncurried arguments.

Do you have any example of CAT coins you want to find the senders on testnet or mainnet?