-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchallenge12.cairo
More file actions
37 lines (30 loc) · 874 Bytes
/
challenge12.cairo
File metadata and controls
37 lines (30 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#[contract]
mod Vault {
use starknet::contract_address::contract_address_to_felt252;
use box::BoxTrait;
struct Storage {
locked: bool,
password: felt252,
}
#[constructor]
fn constructor() {
let tx_info = starknet::get_tx_info().unbox();
let param1: felt252 = tx_info.nonce;
let param2: felt252 = contract_address_to_felt252(tx_info.account_contract_address);
let _password:felt252 = hash::pedersen(param1,param2);
locked::write(true);
password::write(_password);
}
#[external]
fn unlock(_password: felt252) {
if password::read() == _password {
locked::write(false);
}
return();
}
#[view]
fn isComplete() -> bool {
assert(locked::read()==false,'Challenge not resolved');
return(true);
}
}