Couldn't sign tx with kmd: key does not exist in this wallet

Hi guys. I am new to Algorand development and learning to create an AMM protocol using pyteal.
I found this project on github call AlgoSwap. Unfortunately, it is a dead project so I have to ask my question here.
After successfully deploying this AMM application to my Sandbox private network, I was trying to do Add Liquidity for Token 1 and Token 2 flow and had successfully done step 4, sending Token 1 and Token 2 from pooler account to escrow account. But at step 6, sending Liquidity Token from escrow account to pooler account also called refund transaction, when I asks Wallet to sign an atomic transaction group consisting of 3 transactions , it gives me this error: Couldn't sign tx with kmd: key does not exist in this wallet. Here is the scripts:

export ALGORAND_DATA=~/data

export ESCROW_ADDRESS="AQJHY4PQQJ6PFTQUBLTRKU3343FYNTHET4X7G7XPU2LLV3GXKWEVO4HIAY"
export ESCROW_LOGICSIG="BiAHBgEEA6sBqgECMgQjEkAAejIEJRJAAEAyBCQSQAABADMAECISMwAYIQQSEDMBECISEDMBGCEFEhAxFiEGEjEWJRIREDEQJBIQMQkyAxIQMRUyAxIQQgA2MwAQIhIzABghBBIQMwEQIhIQMwEYIQUSEDEWIQYSEDEQJBIQMQkyAxIQMRUyAxIQQgADIyMSQw=="

export MANAGER_INDEX="170"
export VALIDATOR_INDEX="171"
export TOKEN1_INDEX="172"
export TOKEN2_INDEX="173"
export LIQUIDITY_TOKEN_INDEX="174"
export TEST_ACCOUNT_ADDRESS="AMPVQWZ7UEEXLOMCVHA64CCCX5ULW6ISDDQ4IZFKBO5GPM3I5BLXCMV4FU"

goal app call --app-id ${VALIDATOR_INDEX} --app-arg "str:r" --from ${TEST_ACCOUNT_ADDRESS} --app-account ${ESCROW_ADDRESS} --out=txn1.tx

goal app call --app-id ${MANAGER_INDEX} --app-arg "str:r" --from ${TEST_ACCOUNT_ADDRESS} --app-account ${ESCROW_ADDRESS} --out=txn2.tx

goal asset send -a 4667013917 --assetid ${LIQUIDITY_TOKEN_INDEX} -f ${ESCROW_ADDRESS} -t ${TEST_ACCOUNT_ADDRESS} --out=txn3.tx

cat txn1.tx txn2.tx txn3.tx > combinedtxns.tx

goal clerk group -i combinedtxns.tx -o groupedtxns.tx
goal clerk split -i groupedtxns.tx -o split.tx

goal clerk sign -i split-0.tx -o signout-0.tx
goal clerk sign -i split-1.tx -o signout-1.tx
goal clerk sign -i split-2.tx -o signout-2.tx

cat signout-0.tx signout-1.tx signout-2.tx > signout.tx

goal clerk dryrun -t signout.tx --dryrun-dump --dryrun-dump-format json -o withdraw-liq-dr.json

My understanding of this is that I cannot sign the 3rd transaction because it sends asset from Escrow account, not pooler account and I only have private key of pooler.
So my question is how can I do this refund transactions group properly? Thanks!

Welcome to Algorand!

AlgoSwap is more than 1 year old and uses old techniques for smart contracts.
I would strongly recommend not using it as a base for your project as smart contracts have evolved a lot since then.

Now, for your specific error, most likely you need to sign using the escrow logicsig.
At the time AlgoSwap was written, smart contracts indeed had to use logicsig/contract account as escrow accounts: CLI smart signatures - Algorand Developer Portal
This is no more the case: now smart contracts directly control application accounts and this is the proper way to handle escrows now.

1 Like

Thanks for the quick reply and warm welcome!
Indeed I have to use logicsig to sign the third transaction
goal clerk sign -i split-2.tx -o signout-2.tx to goal clerk sign -i split-2.tx -o signout-2.tx -p ../build/escrow.teal. It works now.

This is no more the case: now smart contracts directly control application accounts and this is the proper way to handle escrows now.

Can you give me a full guide on this or a link to a proper tutorial? It would be very much appreciated!
I can see that even Tinyman refund transaction uses logicsig to sign!

There are cases where you may still need a logicsig, e.g., when you want to ensure that there is a single pool for each pair of currencies in TinyMan.

But in general, using inner transaction / application account is better.
See Build with Python - Algorand Developer Portal for a full tutorial
See Smart contract details - Algorand Developer Portal for details about inner transactions

1 Like