Combine assets

+1 vote
Hi, can i have an example code of how can i combine 2 assets into 1?
Lets say i issue 2 assets to a same address, how can i combine it?

TIA~
asked Jan 25, 2016 by otokiru
When you say "combine into one" do you mean you want to create a compound asset that contains the two original ones, so they can never be separated in future? Or just that you want to send them together to some other address, but they can then be separated again by the recipient?
I would like to compound them...
Lets say I want to send personB $25, but i have asset1 of $10, and asset2 of $20, so i wish to combine them into 1 asset so i can make the transfer

1 Answer

0 votes
 
Best answer

You can send two assets together in the same transaction, and they will even sit together in the same transaction output. For example:

multichain-cli chain1 sendtoaddress [address] '{"asset1":10, "asset1":20}'

answered Jan 26, 2016 by MultiChain
selected Jan 26, 2016 by otokiru
Thanks. But what if there's hundreds of assets, then i would need to 1) Get all the assets, 2) Calculate/compare the amount 3) return all the asset names and amount, i think its kind of tedious. Isn't there any simpler way to do this? What about the combineunspent method, possible to make use of it?
I'm afraid there is not currently a way to permanently combine assets together in a single transaction output. But you could use listunspent + createrawtransaction + appendrawchange to send all of the assets in the wallet together to another address.
ok thanks!~~~~
...