How to execute a transaction with only one Coin<SUI> left?

You can use the PaySui transaction type (sui_paySui endpoint) to split up a single coin for use in subsequent transactions:

Pass it the single coin you have in the input_coins array, and then the split amounts you want in amounts. The recipients array should have your own address repeated as many times as amounts you supplied.

This transaction will split up the input coin into all the different amounts, plus a remainder. It uses the remainder to pay the gas for the transaction, and anything left will go back to the sender.

11 Likes

PaySui can also be used to merge coins together, details here:

1 Like