Icon HelpCircleForumIcon Link

⌘K

Icon HelpCircleForumIcon Link

Icon LinkImports

The predicate keyword is used to identify that the program is a predicate.

predicate;

We're going to utilize the Sway standard library Icon Link in our predicate. Delete the template code except for the predicate keyword and copy in the imports below:

use std::{
    tx::{
        tx_witness_data,
        tx_witnesses_count,
        tx_id
    },
    constants::ZERO_B256,
    b512::B512,
    ecr::ec_recover_address
};

Icon LinkTransactions

To construct the MultiSig, it's essential for us to obtain three specific components from the transaction through the standard library:

tx::{
    tx_witness_data,
    tx_witnesses_count,
    tx_id
},
  1. Transaction Witness Data: We'll use this to attach signatures on the transaction.
  2. Transaction Witness Count: This will help us determine the number of signatures attached.
  3. Transaction ID: The hash of the transaction.

Icon LinkConstants

From the constants library, we'll be using ZERO_B256 as a placeholder.

constants::ZERO_B256,

Icon LinkSignatures

We'll need b512 because signatures are of type b512.

b512::B512,

Icon LinkElliptical Curve

Lastly, we will be using ec_recover_address, short for elliptical curve recovery address. It's a function that allows us to cryptographically recover the address that signed a piece of data:

signing_address = ec_recover_address(signed_data, original_data)

This step is crucial for safeguarding the funds and ensuring that only the correct wallets can provide the necessary signatures.

ecr::ec_recover_address