Search code examples
blockchaintransfercosmoscosmos-sdk

Does 'msgMultiSend' of Cosmos coin, guarantee the order of input and output?


I am a coin wallet developer, and I am investigating Cosmos' transfer this time.

Cosmos has msgMultiSend as well as msgSend.

I know that MsgMultiSend sends several transfers using inputs and outputs in the form of an array.

At this time, I wonder if the order of inputs and outputs is matched one on one and guaranteed.

(i.e., whether the recipient matching the first sender of inputs is always guaranteed to be the first of outputs.)

(i.e.

  • transfer 1 : inputs[0] -> outputs[0]
  • transfer 2 : inputs[1] -> outputs[1] ...)

Solution

    • In cosmos 0.45.9, cosmjs 0.28.11, msgMultiSend have inputs that must be the same address. If you have multiple input addresses, you must have multiple signatures to verify them. And when I try to do this, the SDK show error BroadcastTxError: Broadcasting transaction failed with code 4 (codespace: sdk). Log: wrong number of signers; expected 1, got 2: unauthorized at CosmWasmClient.broadcastTx. But if you use the same address, It'll successful. Example on Aura Network Testnet: A070ED2C0557CFED34F48BF009D2E21235E79E07779A80EF49801F5983035F1B. Click JSON to view Raw Data.

    • And the sum token amount of inputs should equal the sum token amount of outputs. If it's not equal, this error will throw Broadcasting transaction failed with code 4 (codespace: bank). Log: sum inputs != sum outputs.

    • You can see the events data of the transaction to know more about this typeUrl. Example: 1 input send to 19 outputs