6. Writing contracts. Scripting.
-- We have to start with definition of a data type representing
-- the key. This is not a part of the contract itself and may be
-- imported into multiple contracts from a _data type library_.
data PgpKey :: curve U8, key Bytes
schema DecentralizedIdentity
-- This defines the atom of the contract state called `Identity`
-- which has data type `PgpKey`.
-- The `owned` keyword means that there is always a party
-- which owns the identity
owned Identity :: PgpKey
-- an implicit part of the story is the fact that owned state
-- is always assigned to a single-use-seal definition, so the
-- proper way of writing the above statement will be
owned Identity :: SingleUseSeal -> PgpKey
-- but we leave the part which repeats for each and every owned
-- state to reduce boilerplate of writing `SingleUseSeal ->`
-- over and over again.
-- This says that to construct contract the user must provide
-- information about exactly one identity
genesis :: Identity
-- Now let's define what a owner of identity can do,
-- He can execute his rights by creating state transitions
-- ("operation" on the state) of predefined forms, like
op Revocation :: old Identity -> new Identity
-- which does what it says: it revokes existing identity
-- and creates a new one.
Last updated
Was this helpful?