with_outputs can be attached to ScriptCall or ScriptCallHandler
an example
What does it do here? Does this mean the expected transaction output for the script? The script call will return some error if the output is not the same as the outputs I attached when executing the script?

    let script_call = ScriptCallHandler::<()>::new(
    .with_inputs(vec![input_predicate, input_from_taker])

This is because each transaction is spending UTXOs, so to give a better model here are some basic facts about the FuelVM

  1. Each Contract is technically represented by a UTXO, when you interact with that a contract that UTXO is spent, and a new one is created
  2. You must declare all UTXOs which will be spend when you send a transaction

And so before sending a transaction you must attach all input UTXOs, and all output UTXOs, which will include any coins transferred, any contracts which are called or change their state, and any changed balances. So you can’t arbitrarily attach outputs on a transaction, and that’s why your tx will fail without those exact outputs, and why you need to call append_variable_outputs on a transaction which mints new coins, to tell the transaction to expect new Outputs from the transaction (and why you need to declare all contract inputs ahead of time)


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