Append_variable_outputs method not found

The append_variable_outputs function should not encounter any issues, but there may be an error with the value of 0.64.

#[warn(unused_imports)]
use fuels::{crypto::SecretKey, prelude::*, types::{Bits256,Bytes32, ContractId, Identity}};
use std::str::FromStr;

#[tokio::main]
async fn main() {
    abigen!(
        Contract(
        name = "MyContract",
        abi = "out/debug/src7_token-abi.json"
    ),
);
    let provider = Provider::connect("https://testnet.fuel.network/v1/graphql").await.unwrap();
    let secret =
        SecretKey::from_str("cc74e38f91112c34aa913592888e3a582850bfeaaa04cbb6914a746a9eb564e1")
            .unwrap();
       
        // Create the wallet
    let wallet = WalletUnlocked::new_from_private_key(secret, Some(provider.clone()));
    
    let contract_id: ContractId  =
    "0x20667443791e287f39703462e179904ba106063fd7c16c5188e9a5ba9e6faa78"
        .parse()
        .expect("Invalid ID");

        let sub_id_array = [0u8; 32];
        let sub_id = Bits256(sub_id_array);

    let contract_instance = MyContract::new(contract_id, wallet.clone());
    let bech32_address = Bech32Address::from_str("fuel140gh2pe9pm96pxep8am03v9djkcz90qxptdumdg3n4m2774surhqt528tg".to_string().as_str()).unwrap();

    println!("bech32_address: {}", bech32_address);
    let address = Address::from(bech32_address);
    println!("address: {}", address);
    // let contract_instance = Script::new(contract_id, wallet.clone());
    let asset_id = contract_instance.methods().asset_id(sub_id).call().await.unwrap();
    let asset = asset_id.value;
    println!("asset {:?}",asset);
    
    let recipient = Identity::Address(wallet.address().into());
    let mint = contract_instance.methods().mint(recipient,sub_id,1).append_variable_outputs(1).call().unwrap();
    // let mint = contract_instance.methods().mint(recipient,sub_id,1).with_outputs(outputs).call().unwrap();
    dbg!(&mint);
  
   
}
[dependencies]

tokio = { version = "1", features = ["macros"] }

tracing = "0.1"

tracing-subscriber = "0.3"

fuels = "0.64.0"

Compilation errorstrong text

no method named `append_variable_outputs` found for struct `ContractCallHandler` in the current scope
method not found in `ContractCallHandler<WalletUnlocked, ()>`

Hi @lopo1 ,

Please see the changelog here:

I’d need to look into this further to see if the method name or behavior has in fact changed for this release, but the above may be helpful to take a look at.

1 Like

We improved how the SDK handles missing variable_outputs. Here are the docs: Variable outputs and messages - The Fuel Rust SDK

TLDR: you should use with_variable_output_policy. 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

1 Like

Thank you very much. This is very useful for me

1 Like

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