-2

I am building a transaction that includes more than one asset in the output of a transaction. After I set up the output and try to build a transaction using getUtxos(outputValue) I get undefined from Nami while Eternal works fine using the same code.

outputValue contains both ada and several other assets.

1 Answer 1

0

Documentation for getUtxos():

cardano.getUtxos(amount, paginate)

cardano.getUtxos(amount?: Value, paginate?: {page: number, limit: number}) : [TransactionUnspentOutput]

TransactionUnspentOutput is a hex encoded bytes string.

enter image description here

Now just deserialize the hex-encoded cbor string, for example in Python using the cbor2 package:

import cbor2   
                                                                                                                                             
utxos = cbor2.loads(bytes.fromhex("YOUR_CBOR_STRING"))
                                                                                                                                                                                                                                                                                                      
for k, v in utxos[1][1][1].items():
    print(k.hex(), v)


                                                                                                                          

enter image description here

1
  • Thank you for the reply. I am aware of how to use getUtxos() method. My issue is that Nami wallet returns "undefined" while Eternl returns a correct list of utxos when I use the same code with both. Looks like Nam's is less efficient in selecting utxos to fulfill the outputs of a transaction. Or is there a different method in Nami other than the default getUtxos()? For example, try and build a tx where you need 3 or 4 NFTs sent from wallet along with some ADA. You will notice that Eternl has no issue, where Nami tried to include all utxos or none.
    – Fourzin
    Sep 20, 2022 at 8:45

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.