How to manage edge cases while transferring ADA - Blockfrost

Hi everyone,

I had a doubt regarding these edge cases :

1st case:
Lets say i have 5 addresses and all have 0.5 ADA. So, user would have total 2.5 ADA in its account.
Can the user still send 1 ADA? (since there is a min 1.17 Ada required in one address)

2nd case:
Lets say i have 2 addresses and one have 1 ADA and other address has 0.8 ADA. So, user would have total 1.8 ADA in its account.
CAn the user send 1.2 ADA?
Will the transaction fee in this case be 0.017 ADA or user would have to pay 0.6 ADA as transaction fee

I am open for any information, suggestion regarding this.
Any pseudo code is more than most welcome hehe.

I am following this sample example to send ADA from one account to other.
( https://github.com/blockfrost/blockfrost-js/tree/master/examples/simple-transaction )

Thanks in advance
Cheers

Isn’t it just 1 ADA and only more, when there are tokens involved?

This cannot be, since they all have to have at least 1 ADA.

But, yes, distributing 2.5 ADA to one --tx-out with 1 ADA and one with 1.5 ADA should be possible.

As far as I have seen it, most wallet apps and cardano-cli transaction build would just raise the fee to balance the transaction, while in cardano-cli transaction build-raw you would have to balance it yourself until the sum of outputs and fee is 1.8 ADA. I would rather gift it to the recipient than raise the fee, but that’s just me.

Hehe thats a nice way to handle it.

@HeptaSean How can i distribute this ? I am very new to all this .

@HeptaSean But if remaining ada can be used as gas fee or sending to the recepeint, that would mean there is no possibility of having less than 1 Ada ever i any utxo right ?

Correct. As long as that protocol parameter is not changed, there can never be an output (and, hence, also never be an input) of less than 1 ADA.

Given your link above, you are trying to do it with the Javascript Blockfrost API. I have never used that, but just played arround with the command line cardano-cli.

The example you are following uses https://github.com/blockfrost/blockfrost-js/blob/master/examples/simple-transaction/src/helpers/composeTransaction.ts to compose the transaction and there you can also see, where the only output used in that simple example is added. At that point, you could also add more outputs, when doing this yourself.

They also add a change address in the case, where the input ADA are more than the output ADA. So, if your input has 2.5 ADA and you just send 1 ADA to someone else, 1.5 ADA minus transaction fee will flow back into a new UTxO at your address.

Yes @HeptaSean i checked this today, that is happening like this only.

But here as you can see here, they are using only utxo of the address at index 0.

So to use utxos of different addresses, i just looped through all the associated addreses which have utxos and i pushed them here (https://github.com/blockfrost/blockfrost-js/blob/master/examples/simple-transaction/src/index.ts#L45)

But as you can see the signing key that they are using is derived and returned over here (https://github.com/blockfrost/blockfrost-js/blob/fb9a55fee07927f8d7c8b0a5aa9efd2d3daf6c77/examples/simple-transaction/src/helpers/key.ts#L45)

And then using this key to sign transaction over here
(https://github.com/blockfrost/blockfrost-js/blob/master/examples/simple-transaction/src/helpers/signTransaction.ts)

So i wanted to know what should i pass as the sign key so that every utxo, which is from any address can be signed.

It would be great if you can help me with this. Not just you anyone hehe.
Or maybe should i make a new post, dont have much experience of using this hehe.