How can I use a configurable block in the latest version of Predicate?

@furnic on the topic How to pass not hard coded addrresses in predicate? sent a link to answer the question of how to provide data to predicate with configurable block Predicates - The Fuel Rust SDK

But if we go to check the latest version of Rust book Predicates - The Fuel Rust SDK then there is no information about configurable. When I try to set configurable I have an error:


So is there a final doc with updates that has full functionality?

The fuels.rs SDK has this feature but it has not made it into a release yet. If you change your version in your cargo.toml from 0.41 to master
fuels = { git = "https://github.com/FuelLabs/fuels-rs", branch = "master"}
You can access the functionality then.

See for more: feat!: add predicate configurables by hal3e · Pull Request #935 · FuelLabs/fuels-rs · GitHub

1 Like

I’ll try it right now!

Hello @SwayStar123
I’m just added fuels-rs from master using this

fuels = { git = "https://github.com/FuelLabs/fuels-rs", branch = "master"}

instead of this

fuels = { version = "0.41", features = ["fuel-core-lib"] }

On my rust test, I’m using inputs and outputs with ScriptCall

   let script_call = ScriptCallHandler::new(
            vec![],
            UnresolvedBytes::default(),
            wallet.clone(),
            provider.clone(),
            Default::default(),
        )
        .with_inputs(vec![input_predicate, input_from_taker])
        .with_outputs(vec![
            output_to_receiver,
            output_to_taker,
            partial_fulfill_output,
            output_asked_change,
        ])
        .tx_params(TxParameters::default().set_gas_price(1));

Also, rust sdk uses fuel_tx::Output and fuels::types::input::Input

but on master version we have this fuels_tx export

Instead of this

And I was forced to install fuel_tx and have some versions issues
Please add Output type export on release version

P.S
Is there any func on fuels-rs that can generate inputs and outputs like that?

looks like you already have something like that

This code

   let output_offered_change = predicate // case 0
            .get_asset_outputs_for_amount(wallet.address(), asset0, 0)
            .iter()
            .find(|out| matches!(out, Output::Change { .. }))
            .unwrap()
            .to_owned();
        println!("output = {:#?}", output_offered_change);

        let output_offered_change = Output::Change { // case 1
            to: Address::from(wallet.address()),
            amount: 0,
            asset_id: asset0,
        };
        println!("output = {:#?}", output_offered_change);

Gives this logs

output = Change {
    to: 0xc5b66e2ce7521c159739026f3682e7abac4cec06d689c2ca261f3d2541585bc2,
    amount: 0,
    asset_id: 0x4e68158aa0dd81c438160a6ef38829363cf96eeef1ae5c6cb3cccb1c52a7e685,
}
output = Change {
    to: 0x5d99ee966b42cd8fc7bdd1364b389153a9e78b42b7d4a691470674e817888d4e,
    amount: 0,
    asset_id: 0x4e68158aa0dd81c438160a6ef38829363cf96eeef1ae5c6cb3cccb1c52a7e685,
}

It looks the same, but if I put case0 to with_outputs it does not work with error (that means output don’t work)
With case 1 it works well :thinking:

thread 'local_tests::cancel_order_test::cancel_order_test' panicked at 'assertion failed: `(left == right)`
  left: `1000000000`,
 right: `0`', tests/local_tests/cancel_order_test.rs:83:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
test local_tests::cancel_order_test::cancel_order_test ... FAILED

It happens because addresses are different, case0 used predicate address, case1 uses wallet address

I figured out what was going on, I had to call

wallet.get_asset_outputs_for_amount(wallet.address(), asset0, 0);
1 Like