What difference between rust sdk script input/output types?

  • OutputCoin - It doesn’t have any malleable fields. You can use it when during transaction creation, you already know the recipient, asset, and amount.
  • OutputVariable - All fields are malleable. It means you don’t know who is the receiver of what asset and what amount of that asset during the creation of the transaction. You need to set them during the execution of the script.
  • OutputChange - Only the amount field is malleable. It means that during the transaction, you know who and what asset will receive, but you don’t know the amount of this value. The amount will be known at the end of the script execution. The typical use case is receiving a not used gas fee(if the transaction was cheaper than during the dry run, the user might receive some money back).

It is better to use OutputCoin where it is possible because, in this case, the blockchain can chain transactions into a dependency graph with known values and parallel execution.

2 Likes