docs/src/calling-contracts/variable-outputs.md
Sometimes, the contract you call might transfer funds to a specific address, depending on its execution. The underlying transaction for such a contract call has to have the appropriate number of variable outputs to succeed.
<!-- variable_outputs:example:end -->Let's say you deployed a contract with the following method:
{{#include ../../../e2e/sway/contracts/token_ops/src/main.sw:variable_outputs}}
When calling transfer_coins_to_output with the SDK, you can specify the number of variable outputs:
{{#include ../../../examples/contracts/src/lib.rs:variable_outputs}}
with_variable_output_policy sets the policy regarding variable outputs. You can either set the number of variable outputs yourself by providing VariableOutputPolicy::Exactly(n) or let the SDK estimate it for you with VariableOutputPolicy::EstimateMinimum. A variable output indicates that the amount and the owner may vary based on transaction execution.
Note: that the Sway
lib-stdfunctionmint_to_addresscallstransfer_to_addressunder the hood, so you need to callwith_variable_output_policyin the Rust SDK tests like you would fortransfer_to_address.