A type for cheststype chest
A type for chest keystype chest_key
type chest_opening_result = ["Ok_opening", bytes] | ["Fail_decrypt"] | ["Fail_timelock"];
A type for the result of chest opening, see
let open_chest : chest_key => chest => nat => chest_opening_result
let call_view : string => 'arg => address => option <'ret>
let constant : string => 'a
new signature for originate_from_file:
let originate_from_file = (filepath: string, entrypoint: string , views : list <'string> , init: michelson_program, balance: tez) => [address, michelson_program, int]
Originate a contract with a path to the contract file, an entrypoint, a list of views, an initial storage and an initial balance.
let create_chest : bytes => nat => [chest , chest_key]
Generate a locked value, the RSA parameters and encrypt the payload. Also returns the chest key Exposes tezos timelock library function create_chest_and_chest_key
let create_chest_key : chest => nat => chest_key
Unlock the value and create the time-lock proof. Exposes tezos timelock library function create_chest_key.
Extensive documentation about timelock can be found here. Here is an example of a contract trying to open a chest and the corresponding tests to trigger all error kinds:
Tezos documentation on views can be found here
On-chain views are named routines attached to your contract allowing
another contract to call them to get a "view" of your contract current
storage. It cannot modify your storage nor emit operations. These
routines can either simply return your contract storage or apply some
kind of processing to it: they take your current storage, a parameter
and returns the data of your choice. Note that parameter and return
types can be anything except
ticket. Views are named after their declaration name and can be
compiled in two ways:
by passing their names to the command line option
ligo compile contract --views v1,v2,v3)
by annotating their declarations in your code with
Important: the first way (
--views) will override any annotated declarations
Given a very simple contract having a storage of type
are a few legit views:
[@view]attribute is only supported for top-level functions.
The use of
[@view]attribute anywhere other than top-level will be ignored.
A few primitives have a slightly different meaning when executed as part of a view:
Tezos.get_balancerepresents the current amount of mutez held by the contract attached to the view
Tezos.get_senderrepresents the caller of the view
Tezos.get_amountis always 0 mutez
Tezos.get_self_addressrepresents the contract attached to the view
On the caller side, the primitive
Tezos.call_view will allow you to call another contract view and get its result by providing the view name; the contract address and the parameter of the view. If the address is nonexistent; the name does not match of of the contract
view or the parameter type do not match,
Tezos.call_view will return
The new primitive
Tezos.constant allows you to use a predefined constant already registered on chain.
It accepts a hash in the form of a string and will require a type annotation.