Is it possible to add time lock condition on predicates, for example a predicate will return false after a timestamp has passed?

Is it possible to add time lock condition on predicates, for example a predicate will return false after a timestamp has passed?

7 Likes

Predicate cannot access the current timestamp. The opcode TIME is not allowed in predicates. That’s because predicates can only access the data in a transaction but cannot view the current chain state.

4 Likes

Note however that this can be achieved indirectly by writing a script which performs the timestamp check, and then having the predicate check that the bytecode hash of the spending script matches this script.

e.g.

predicate;

fn main() {
    assert(std::tx::tx_script_bytecode_hash() == TIMELOCK_SCRIPT_HASH);
}

where TIMELOCK_SCRIPT_HASH is the hash of :

script;

fn main() {
    assert(std::block::timestamp < TIME);
}

and TIME is the threshold time.

4 Likes