1

I'm following this guide on metadata transactions with the cardano wallet server. My goal is to prove the existence of a given IPFS hash at a certain point in time. I don't need to send or receive ADA from anyone so as the guide mentions I'm sending 1,000,000 lovelace to myself. I have these two transactions (one & two) on testnet that have been in a pending state for >1 hour.

The first transaction shows ~900 ADA coming from one of my addrs and then 1 ADA going to my address that I specified and then the remainder going to another addr in my wallet. The second transaction is similar but has 3 inputs and 2 outputs.

I'm trying to understand how the eUTXO model works in this situation, I understand that I'm getting all of the ADA back but while these transactions are pending I apparently can't spend anything because I tried a third transaction but it failed saying I don't the 1 ADA required. After some more research I see that I should've specified a TTL so that it doesn't take forever but I have a few questions about how I should I approach this.

  1. Why is the lockup inconsistent? I only need 1 ADA + fee, so why did the first transaction lock up 900 ADA and then the second locked up the remaining ~90? If it is ok with 90 is it possible to specify a smaller number?

  2. What's with the hour long pending state? I have over 150 confirmations, is this due to congestion on testnet? Any suggestions on a TTL for this type of transaction?

  3. The wallet provides several addresses for privacy but in this application design I don't want privacy, the intention is to make the metadata public so it really shouldn't matter what address I use as long as its consistent right? Is there a typical method for selecting an address for public transparancy or just pick the first one?

EDIT Just a moment ago I realized my local node was showing it was 99.8% synced and I just sent another transaction that updated to in_ledger status really quickly so I'm guessing the sync was why I was seeing the pending status for so long on my local node but I'm still interested in questions 1 & 3 above.

1 Answer 1

1

Seeing as you've solved the mystery around the pending state transactions I will try my best to answer questions 1 and 3.

Question 1: Inconsistent Lockup of UTXOs

Wallets use CIP 2 - Coin Selection Algorithms for Cardano to decide which UTxOs to consume.

There are two main algorithms used by Cardano Wallet:

  • Largest-First
  • Random-Improve

In general, Cardano Wallet gives priority to the Random-Improve algorithm, as experimental evidence shows that it performs better at minimising dust and maintaining a UTxO set with useful outputs. (See Self Organisation in Coin Selection for more details.)

However, in rare cases, the Random-Improve algorithm may fail to produce a result. In such cases, Cardano Wallet will fall back to the Largest-First algorithm.

Looking into the transaction history here I can see that the wallet had a limited set of UTxOs to work with, one output with 900 ADA, one with 90 ADA and single ADA outputs here and there. In this case it looks like the random-improve algorithm selected the 900 ADA UTxO first.

Given this knowledge, it does make sense to have multiple evenly distributed UTxOs available for your wallet if you need multiple concurrent transactions between blocks. Wallets like Eternl do this with their "Advanced UTxO Management" feature.

Question 3: Addresses to Use if Privacy isn't needed

Yes it doesn't matter which address you use, as the wallet will always have full control to spend UTxOs across its previously derived addresses. For example wallets like Nami always use the first derived address. It is also worthwhile mentioning that there is no privacy between transactions if all your derived addresses use the same staking key, which is the case for most wallets today. An thread from reddit highlights this.

2
  • Great, thanks for the info! When my node is synced the transactions settle in ~30 sec so it won't be an issue but just for my understanding; I think I get why the cardano-wallet has the utxo distribution endpoint now. I'm currently using a high level API that simplifies transaction building but if I wanted more control I could use a lower level client and use one of the algorithms you mentioned or implement my own utxo selection method? It doesn't really matter when transactions are expected to settle in a short period but for certain smart contract durations it might end up being important.
    – B Rad C
    Apr 22, 2022 at 18:47
  • Yeah for ultimate flexibility there are already quite a few options around lower level SDKs or clients depending on the tech stack you are using. I personally find cardano-wallet to be a tad heavy-weight and opinionated so I use cardano-cli for ad-hoc transactions and CardanoSharp with my C# code.
    – keefie
    Apr 23, 2022 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.