Send multiply assets in one transaction

+3 votes
Hi, so, two different users, sent me 2 different assets, A and B, obviously, UTXOs with this assets resides in different transactions. What I want, is to consume this UTXOs and send TX to another user with assets A+B in one transaction? Just like we do with native coin, combining UTXOs value until it become >= the value we want to send. All my tries failed with typical node error, mandatory-script-verify-flag. All inputs are signed as it needs to be done with native coin inputs.

Second question, so if the case above is not possible and I will need to create two TXs to send asset A and B, will I be able to send assets A and B in one transaction in case this assets resides in one UTXO from one user?

Thanks in advance
asked Apr 16, 2023 by Tester

1 Answer

0 votes

It's certainly possible to send two assets in a single transaction, for example:

sendfrom <from-address> <to-address> '{"asset1":50,"asset2":1.5}'

(This assumes you are using the Linux command line.)

answered Apr 16, 2023 by MultiChain
I am building transaction from scratch in my wallet app, so command line is not the case. I take first UTXO with asset A and second UTXO with asset B, put them in TX as inputs, then form assets A and B metadata according to multichain documentation, put it in locking script as pay key hash pattern, sign inputs, etc. In other words - doing all the TX stuff in code. And TXs works perfectly for the case where I am sending only one asset type and consuming one UTXO, when I am trying to reproduce it consuming two or more UTXOs with different assets, and send such TX, Im getting constant mandatory-script-verify-flag error from node.
There are many possible problems. The best approach is to use MultiChain to create a transaction, and then compare the one you created against it to check it is the same. But I guess the problem might be: (a) the quantity of each asset across inputs and outputs is not the same, (b) the signatures are not covering every part of the transaction as necessary.
...