What difference between rust sdk script input/output types?

Hi guys

In rust sdk we have few input and output types

Input types:
ResourceSigned - input from the caller
ResourcePredicate - some predicate balance?
Contract - is it like nft?

Output types:
Coin - output coin amount
Contract - ?
Message - ?
Change - its the address which will get the rest of the asset
Variable - ?
ContractCreated - >

Can you explain please what the difference?

You can read more about Input and Output types in the Fuel spec book and the GraphQL API docs:

Inputs:
https://specs.fuel.network/master/protocol/tx_format/input.html

Outputs:
https://specs.fuel.network/master/protocol/tx_format/output.html

1 Like

I’m trying to understand output types as well… specifically the difference between OutputVariable vs OutputCoin vs OutputChange.

Does my script need to explicitly transfer assets to OutputChange? Or will change automatically appear there?

So, as I get
OutputVariable - I have no idea what that is
OutputCoin - it’s like how much you want to get from predicate
OutputChange - it’s where you want to transfer the rest of the money, without OutputChange rest of the money will be burned

  • 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

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.