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.
I would have to speculate, but maybe @shb or @tnowacki have the historical context here.
The main thing I notice though is that Coin for Aptos does not have key so it must be stored in a CoinStore and that store keeps track of events on the balance of that coin for that account.
In Sui’s Move, Coin has both key and store so can be owned directly or stored in some other object, and Events are not currently first class on-chain objects, so there is no role for CoinStore to play.
@icebear.near, I’m curious what motivated your question – is there some feature of CoinStore that you are missing when writing Move for Sui?
I read some contracts written in Sui move that require user supply resources as entry function arguments, also I read some contracts written in Aptos move and realize that they’re not doing the same way. And with aptos CoinStore, I dont have to deal with the one-gas-resource-left in wallet like SUI
Got it, yes – this is a difference in Sui’s object model vs Aptos’, you can read more about the reasons for it here. Regarding the “one-gas-resource-left” issue, we have some plans in the pipeline to simplify (and in some cases, automate) this process so that we get the safety and parallelism benefits of explicitly specifying objects in entry functions without the cognitive overhead of coin management.
One of these features is Programmable Transactions, which will allow you to write a single transaction that uses one coin to pay for gas and to pay within the transaction as well. The other is something we call “gas smashing” which will allow you to pay for a transaction with multiple gas coins, which will get combined in the process.
The PaySui transaction type (sui_paySui endpoint 8) allows you to divide a single coin into smaller amounts for use in future transactions. To use this transaction type, you need to provide the input coin in the input_coins array and specify the split amounts in the amounts array. Additionally, the recipients array should contain your own address repeated for as many times as the split amounts you provided.
When you execute this transaction, the input coin will be divided into the specified split amounts, along with a remainder. The remainder will be used to pay for the gas fees of the transaction, and any leftover amount will be returned to the sender. This feature provides flexibility in managing your cryptocurrency assets and enables you to use them efficiently in subsequent transactions.