Obtaining the "to" Address for a Change Output

Hey all,

Below is a snip of a loop i have in Sway, going over the outputs in the tx, It simply logs the output type, asset_id, an “to” address.

The end goal of this loop (not implemented) is when i find the output type Output::Change, I want to also discover what the “to” address is and validate the change is going back to a specific address.

However when I log the results of these function calls. For the Change output I get a None in place where I would expect the change return address, and also, a None in the asset id place.

I’m assuming these fields are not populated yet in this part of the transactions execution?

      let out_count = output_count();
      let mut j = 0;
      while j < out_count {

          let o_ass_id = output_asset_id(j);

          let o_ass_to = output_asset_to(j);

          let o_type = output_type(j);

          j += 1;

Logged output: Ok("None"), Ok("None"), Ok("Change")

Ok("None")  --> output asset id (should be the default asset id)
Ok("None")  --> output asset to address (where the output has the change to go back to)
Ok("Change")  --> Output type (Change)

Is there any way I can investigate the Change to address at this point in the execution? Or is there another technique?


from outputs.sw this explains the None for the asset id and “to”

pub fn output_asset_id(index: u64) -> Option<AssetId> {
    match output_type(index) {
        Output::Coin => Some(AssetId::from(__gtf::<b256>(index, GTF_OUTPUT_COIN_ASSET_ID))),
        _ => None,

pub fn output_asset_to(index: u64) -> Option<b256> {
    match output_type(index) {
        Output::Coin => Some(__gtf::<b256>(index, GTF_OUTPUT_COIN_TO)),
        _ => None,

So i guess is there any way to investivate the output change to address at all?

In metadata.rs in the fuel-vm there doesn’t look like there are any GTFArgs for “::OutputChange”

Hey @Antony, this functionality is missing at the moment.

You can track the status of the issue here:

I’ll reach out to our VM team and check on the status of it.

1 Like

Hi @david , thanks for that! :slight_smile: