The predicate keyword is used to identify that the program is a predicate.
predicate;
We're going to utilize the Sway standard library 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
};
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
},
From the constants library, we'll be using ZERO_B256
as a placeholder.
constants::ZERO_B256,
We'll need b512
because signatures are of type b512
.
b512::B512,
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