Multi-sig predicate created from contract

Hi @david. Thank you for the predicates workshop you gave some weeks ago.

Our use case involves third-party signatures before a tx is made, but we don’t want to create a one-time use multi-sig wallets for each. So creation of a predicate with the funds to send, then waiting for the correct signature is a really good one.

I was looking the implementation samples, but its a little scarce.

  1. Do you have a github folder with the example you gave in the youtube?

  2. Do you have an example of a predicate created from a contract.

  3. In the example given, you return ‘predicate’ from the predicate - the bytecode hash i presume. In a multisig flow, should i then send the bytecode off-chain to the other signatures?

1 Like

Hey @carlos, glad my talk on predicates was helpful! And your use case sounds perfect for predicates.

  1. Which example specifically were you referring to? We have people on our team building both multi-sig predicates and EVM-wallet (Metamask) predicates, but neither of them are complete yet.
  2. Predicates aren’t really “created”, but theoretically it would be possible for a contract to calculate the address of a predicate and transfer funds to it. However, this would be quite complex today (you’d need to generate the entire predicate bytecode, then calculate the predicate root), so realistically we need to build some tooling for this.
  3. I’m not sure what you mean “return ‘predicate’ from the predicate”, are you referring to this code snippet?
fn get_predicate(eth_address: &[u8; 20], provider: Provider) -> Predicate {
    let padded_address = pad_address(eth_address);
    let configurables = SimpleSigPredicateConfigurables::new()
        .set_PREDICATE_ADDR(Bits256(padded_address));
  
    let predicate_data = SimpleSigPredicateEncoder::encode_data(0);
  
    let mut predicate: Predicate = Predicate::load_from(BIN_PATH)
    .unwrap()
    .with_data(predicate_data)
    .with_configurables(configurables);
  
    predicate.set_provider(provider);
  
    predicate
}

Thanks for your reply.

  1. I got send the multisig predicate example. At this moment i am looking for a reference to call/fund a predicate within a contract.

  2. Indeed struggling with the concept. But the ‘predicate-with-configurable-constants’ paragraph in Fuel-ts docs is what i need. ( i think) The created Predicate instance - is how it is mentioned there.

That said. As in our case the funds deposited are hold by a contract. We need to place the logic described above in the contract. If the above snipped you send is on a contract. How en what is load_from(BIN_PATH)?

  1. Yes this bit. Do you have it in ‘its context’? If i call the get_predicate() what is the response?

Hey @carlos, sorry for the really late reply!

If by some chance you’re still on this issue, the answer to this part is that that code returns a Predicate struct from the Rust SDK.

hey @David do you have any updates on progress on the EVM wallet predicates you mentioned here as being built?

Seems like it should be fairly straightforward to have metamask → fuel interactions by mainnet but curious to see how it’s being implemented.

Hey @bertie, the EVM predicate is currently in development, we uncovered a few bugs while building it which slowed down the progress.

You can see the current code here, we should have progress on it in the coming weeks.