Skip to main content

Guards

create-capability-guard

capability  -> bool  guard

Creates a guard that will enforce that CAPABILITY is acquired.

(create-capability-guard (BANK_DEBIT 10.0))
(create-capability-guard (BANK_DEBIT 10.0))

create-capability-pact-guard

capability  -> bool  guard

Creates a guard that will enforce that CAPABILITY is acquired and that the currently-executing defpact is operational.

(create-capability-pact-guard (ESCROW owner))
(create-capability-pact-guard (ESCROW owner))

create-module-guard

name string  guard

Defines a guard by NAME that enforces the current module admin predicate.

create-pact-guard

name string  guard

Defines a guard predicate by NAME that captures the results of 'pact-id'. At enforcement time, the success condition is that at that time 'pact-id' must return the same value. In effect this ensures that the guard will only succeed within the multi-transaction identified by the pact id.

create-principal

guard guard  string

Create a principal which unambiguously identifies GUARD.

(create-principal (read-keyset 'keyset))(create-principal (keyset-ref-guard 'keyset))(create-principal (create-module-guard 'module-guard))(create-principal (create-user-guard 'user-guard))(create-principal (create-pact-guard 'pact-guard))
(create-principal (read-keyset 'keyset))(create-principal (keyset-ref-guard 'keyset))(create-principal (create-module-guard 'module-guard))(create-principal (create-user-guard 'user-guard))(create-principal (create-pact-guard 'pact-guard))

create-user-guard

closure  -> bool  guard

Defines a custom guard CLOSURE whose arguments are strictly evaluated at definition time, to be supplied to indicated function at enforcement time.

is-principal

principal string  bool

Tell whether PRINCIPAL string conforms to the principal format without proving validity.

(enforce   (is-principal 'k:462e97a099987f55f6a2b52e7bfd52a36b4b5b470fed0816a3d9b26f9450ba69)   "Invalid account structure: non-principal account")
(enforce   (is-principal 'k:462e97a099987f55f6a2b52e7bfd52a36b4b5b470fed0816a3d9b26f9450ba69)   "Invalid account structure: non-principal account")

keyset-ref-guard

keyset-ref string  guard

Creates a guard for the keyset registered as KEYSET-REF with 'define-keyset'. Concrete keysets are themselves guard types; this function is specifically to store references alongside other guards in the database, etc.

typeof-principal

principal string  string

Return the protocol type of a given PRINCIPAL value. If input value is not a principal type, then the empty string is returned.

(typeof-principal 'k:462e97a099987f55f6a2b52e7bfd52a36b4b5b470fed0816a3d9b26f9450ba69)
(typeof-principal 'k:462e97a099987f55f6a2b52e7bfd52a36b4b5b470fed0816a3d9b26f9450ba69)

validate-principal

guard guard principal string  bool

Validate that PRINCIPAL unambiguously identifies GUARD.

(enforce (validate-principal (read-keyset 'keyset) account) "Invalid account ID")
(enforce (validate-principal (read-keyset 'keyset) account) "Invalid account ID")

Receive important developer updates