2020-02-05 08:27:56 +04:00
|
|
|
---
|
|
|
|
id: current-reference
|
2020-02-26 21:31:58 +04:00
|
|
|
title: Tezos - Things relating to the current execution context
|
2020-02-05 08:27:56 +04:00
|
|
|
---
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
import Syntax from '@theme/Syntax';
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
# Tezos.balance
|
2020-02-05 08:27:56 +04:00
|
|
|
|
|
|
|
Get the balance for the contract.
|
|
|
|
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
|
|
|
|
<Syntax syntax="pascaligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```pascaligo
|
2020-02-26 21:31:58 +04:00
|
|
|
function main (const p : unit; const s: tez) : list (operation) * tez is
|
|
|
|
((nil : list (operation)), Tezos.balance)
|
2020-02-05 08:27:56 +04:00
|
|
|
```
|
2020-02-26 21:31:58 +04:00
|
|
|
|
|
|
|
> Note that `balance` and `Current.balance` are *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="cameligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```cameligo
|
2020-02-26 21:31:58 +04:00
|
|
|
let main (p,s : unit * tez) = ([] : operation list), Tezos.balance
|
2020-02-05 08:27:56 +04:00
|
|
|
```
|
2020-02-26 21:31:58 +04:00
|
|
|
|
|
|
|
> Note that `balance` and `Current.balance` are *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="reasonligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```reasonligo
|
2020-02-26 21:31:58 +04:00
|
|
|
let main = ((p,s) : (unit, tez)) =>
|
|
|
|
([]: list (operation), Tezos.balance);
|
2020-02-05 08:27:56 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `balance` and `Current.balance` are *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
## Tezos.now
|
2020-02-05 08:27:56 +04:00
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
Returns the current time as a [unix timestamp](https://en.wikipedia.org/wiki/Unix_time).
|
2020-02-05 08:27:56 +04:00
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
In LIGO, timestamps are type compatible in operations with
|
|
|
|
integers. This lets you set for instance time constraints for your
|
|
|
|
smart contracts like this:
|
2020-02-05 08:27:56 +04:00
|
|
|
|
|
|
|
### Examples
|
|
|
|
|
|
|
|
#### 24 hours from now
|
2020-03-04 17:19:00 +04:00
|
|
|
|
|
|
|
<Syntax syntax="pascaligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```pascaligo group=b
|
2020-02-26 21:31:58 +04:00
|
|
|
const today: timestamp = Tezos.now;
|
|
|
|
const one_day: int = 86_400;
|
2020-02-05 08:27:56 +04:00
|
|
|
const in_24_hrs: timestamp = today + one_day;
|
|
|
|
const some_date: timestamp = ("2000-01-01T10:10:10Z" : timestamp);
|
|
|
|
const one_day_later: timestamp = some_date + one_day;
|
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `now` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="cameligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```cameligo group=b
|
2020-02-26 21:31:58 +04:00
|
|
|
let today: timestamp = Tezos.now
|
|
|
|
let one_day: int = 86_400
|
2020-02-05 08:27:56 +04:00
|
|
|
let in_24_hrs: timestamp = today + one_day
|
|
|
|
let some_date: timestamp = ("2000-01-01t10:10:10Z" : timestamp)
|
|
|
|
let one_day_later: timestamp = some_date + one_day
|
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.time` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="reasonligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```reasonligo group=b
|
2020-02-26 21:31:58 +04:00
|
|
|
let today: timestamp = Tezos.now;
|
|
|
|
let one_day: int = 86_400;
|
2020-02-05 08:27:56 +04:00
|
|
|
let in_24_hrs: timestamp = today + one_day;
|
|
|
|
let some_date: timestamp = ("2000-01-01t10:10:10Z" : timestamp);
|
|
|
|
let one_day_later: timestamp = some_date + one_day;
|
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.time` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
|
|
|
|
#### 24 hours ago
|
2020-02-26 21:31:58 +04:00
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
|
|
|
|
<Syntax syntax="pascaligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```pascaligo group=c
|
2020-02-26 21:31:58 +04:00
|
|
|
const today: timestamp = Tezos.now;
|
|
|
|
const one_day: int = 86_400;
|
2020-02-05 08:27:56 +04:00
|
|
|
const in_24_hrs: timestamp = today - one_day;
|
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `now` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="cameligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```cameligo group=c
|
2020-02-26 21:31:58 +04:00
|
|
|
let today: timestamp = Tezos.now
|
|
|
|
let one_day: int = 86_400
|
2020-02-05 08:27:56 +04:00
|
|
|
let in_24_hrs: timestamp = today - one_day
|
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.time` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="reasonligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```reasonligo group=c
|
2020-02-26 21:31:58 +04:00
|
|
|
let today: timestamp = Tezos.now;
|
|
|
|
let one_day: int = 86_400;
|
2020-02-05 08:27:56 +04:00
|
|
|
let in_24_hrs: timestamp = today - one_day;
|
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.time` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
#### Comparing Timestamps
|
2020-02-05 08:27:56 +04:00
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
You can also compare timestamps using the same comparison operators as
|
|
|
|
for numbers
|
2020-02-05 08:27:56 +04:00
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
|
|
|
|
<Syntax syntax="pascaligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```pascaligo group=c
|
2020-02-26 21:31:58 +04:00
|
|
|
const not_tommorow: bool = (Tezos.now = in_24_hrs)
|
2020-02-05 08:27:56 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `now` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="cameligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```cameligo group=c
|
2020-02-26 21:31:58 +04:00
|
|
|
let not_tomorrow: bool = (Tezos.now = in_24_hrs)
|
2020-02-05 08:27:56 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.time` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="reasonligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```reasonligo group=c
|
2020-02-26 21:31:58 +04:00
|
|
|
let not_tomorrow: bool = (Tezos.now == in_24_hrs);
|
2020-02-05 08:27:56 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.time` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
## Amount
|
2020-02-05 08:27:56 +04:00
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
Get the amount of tez provided by the sender to complete this
|
|
|
|
transaction.
|
2020-02-05 08:27:56 +04:00
|
|
|
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
|
|
|
|
<Syntax syntax="pascaligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```pascaligo
|
2020-02-26 21:31:58 +04:00
|
|
|
function threshold (const p : unit) : int is
|
|
|
|
if Tezos.amount = 100tz then 42 else 0
|
2020-02-05 08:27:56 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `amount` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="cameligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```cameligo
|
2020-02-26 21:31:58 +04:00
|
|
|
let threshold (p : unit) : int = if Tezos.amount = 100tz then 42 else 0
|
2020-02-05 08:27:56 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.amount` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="reasonligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```reasonligo
|
2020-02-26 21:31:58 +04:00
|
|
|
let threshold = (p : unit) : int =>
|
|
|
|
if (Tezos.amount == 100tz) { 42; } else { 0; };
|
2020-02-05 08:27:56 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.amount` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
## Sender
|
2020-02-05 08:27:56 +04:00
|
|
|
|
|
|
|
Get the address that initiated the current transaction.
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
|
|
|
|
<Syntax syntax="pascaligo">
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
```pascaligo
|
2020-02-26 21:31:58 +04:00
|
|
|
function main (const p : unit) : address is Tezos.sender
|
2020-02-25 17:13:25 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `sender` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="cameligo">
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
```cameligo
|
2020-02-26 21:31:58 +04:00
|
|
|
let main (p: unit) : address = Tezos.sender
|
2020-02-25 17:13:25 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.sender` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="reasonligo">
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
```reasonligo
|
2020-02-26 21:31:58 +04:00
|
|
|
let main = (p : unit) : address => Tezos.sender;
|
2020-02-25 17:13:25 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.sender` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
## Address
|
|
|
|
|
|
|
|
Get the address associated with a value of type `contract`.
|
2020-02-25 17:13:25 +04:00
|
|
|
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
|
|
|
|
<Syntax syntax="pascaligo">
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
```pascaligo
|
|
|
|
function main (const p : key_hash) : address is block {
|
2020-02-26 21:31:58 +04:00
|
|
|
const c : contract (unit) = Tezos.implicit_account (p)
|
|
|
|
} with Tezos.address(c)
|
2020-02-25 17:13:25 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `implicit_account` and `address` are *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="cameligo">
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
```cameligo
|
|
|
|
let main (p : key_hash) =
|
2020-02-26 21:31:58 +04:00
|
|
|
let c : unit contract = Tezos.implicit_account p
|
|
|
|
in Tezos.address c
|
2020-02-25 17:13:25 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.implicit_account` and `Current.address` are
|
|
|
|
> *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="reasonligo">
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
```reasonligo
|
|
|
|
let main = (p : key_hash) : address => {
|
2020-02-26 21:31:58 +04:00
|
|
|
let c : contract (unit) = Tezos.implicit_account (p);
|
|
|
|
Tezos.address (c);
|
2020-02-25 17:13:25 +04:00
|
|
|
};
|
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.implicit_account` and `Current.address` are
|
|
|
|
> *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
## Self Address
|
2020-02-25 17:13:25 +04:00
|
|
|
|
|
|
|
Get the address of the currently running contract.
|
2020-02-05 08:27:56 +04:00
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
|
|
|
|
<Syntax syntax="pascaligo">
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
```pascaligo
|
2020-02-26 21:31:58 +04:00
|
|
|
function main (const p : unit) : address is Tezos.self_address
|
2020-02-25 17:13:25 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `self_address` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="cameligo">
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
```cameligo
|
2020-02-26 21:31:58 +04:00
|
|
|
let main (p : unit) : address = Tezos.self_address
|
2020-02-25 17:13:25 +04:00
|
|
|
```
|
2020-02-05 08:27:56 +04:00
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.self_address` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="reasonligo">
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
```reasonligo
|
2020-02-26 21:31:58 +04:00
|
|
|
let main = (p : unit) : address => Tezos.self_address;
|
2020-02-25 17:13:25 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.self_address` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
## Implicit Account
|
2020-02-25 17:13:25 +04:00
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
Get the default contract associated with an on-chain key-pair. This
|
|
|
|
contract does not execute code, instead it exists to receive tokens on
|
|
|
|
behalf of a key's owner.
|
2020-02-05 08:27:56 +04:00
|
|
|
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
|
|
|
|
<Syntax syntax="pascaligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```pascaligo
|
2020-02-26 21:31:58 +04:00
|
|
|
function main (const kh: key_hash) : contract (unit) is
|
|
|
|
Tezos.implicit_account (kh)
|
2020-02-05 08:27:56 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `implicit_account` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="cameligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```cameligo
|
2020-02-26 21:31:58 +04:00
|
|
|
let main (kh : key_hash) : unit contract = Tezos.implicit_account kh
|
2020-02-05 08:27:56 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.implicit_account` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="reasonligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```reasonligo
|
2020-02-26 21:31:58 +04:00
|
|
|
let main = (kh : key_hash): contract (unit) =>
|
|
|
|
Tezos.implicit_account (kh);
|
2020-02-05 08:27:56 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.implicit_account` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
## Source
|
2020-02-25 17:13:25 +04:00
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
Get the _originator_ (address) of the current transaction. That is, if
|
|
|
|
a chain of transactions led to the current execution get the address
|
|
|
|
that began the chain. Not to be confused with `Tezos.sender`, which
|
|
|
|
gives the address of the contract or user which directly caused the
|
|
|
|
current transaction.
|
2020-02-25 17:13:25 +04:00
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> ⚠️ There are a few caveats you should keep in mind before using
|
|
|
|
> `Tezos.source` over `Tezos.sender`:
|
2020-02-25 17:13:25 +04:00
|
|
|
>
|
2020-02-26 21:31:58 +04:00
|
|
|
> 1. `Tezos.source` will never be a contract, so if you want to allow
|
|
|
|
> contracts (multisigs etc) to operate your contract, you need to
|
|
|
|
> use `Tezos.sender`
|
|
|
|
> 2. https://vessenes.com/tx-origin-and-ethereum-oh-my/ -- in general
|
|
|
|
> it is somewhat unsafe to assume that `Tezos.source` understands
|
|
|
|
> everything that is going to happen in a transaction. If
|
|
|
|
> `Tezos.source` transfers to a malicious (or sufficiently
|
|
|
|
> attackable) contract, that contract might potentially transfer to
|
|
|
|
> yours, without `Tezos.source`'s consent. So if you are using
|
|
|
|
> `Tezos.source` for authentication, you risk being confused. A
|
|
|
|
> good historical example of this is bakers paying out delegation
|
|
|
|
> rewards. Naive bakers did (and probably still do) just use
|
|
|
|
> tezos-client to transfer to whatever KT1 delegates they had, even
|
|
|
|
> if those KT1 were malicious scripts.
|
2020-02-25 17:13:25 +04:00
|
|
|
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
|
|
|
|
<Syntax syntax="pascaligo">
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
```pascaligo
|
2020-02-26 21:31:58 +04:00
|
|
|
function main (const p: unit) : address is Tezos.source
|
2020-02-25 17:13:25 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `source` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="cameligo">
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
```cameligo
|
2020-02-26 21:31:58 +04:00
|
|
|
let main (p : unit) : address = Tezos.source
|
2020-02-25 17:13:25 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.source` is *deprecated*.
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="reasonligo">
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
```reasonligo
|
2020-02-26 21:31:58 +04:00
|
|
|
let main = (p : unit) : address => Tezos.source;
|
2020-02-25 17:13:25 +04:00
|
|
|
```
|
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> Note that `Current.source` is *deprecated*.
|
2020-03-04 17:19:00 +04:00
|
|
|
|
|
|
|
</Syntax>
|
|
|
|
|
2020-02-25 17:13:25 +04:00
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
## Failwith
|
2020-02-25 17:13:25 +04:00
|
|
|
|
|
|
|
Cause the contract to fail with an error message.
|
2020-02-05 08:27:56 +04:00
|
|
|
|
2020-02-26 21:31:58 +04:00
|
|
|
> ⚠ Using this currently requires in general a type annotation on the
|
|
|
|
> `failwith` call.
|
2020-02-05 08:27:56 +04:00
|
|
|
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
|
|
|
|
<Syntax syntax="pascaligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```pascaligo
|
2020-02-26 21:31:58 +04:00
|
|
|
function main (const p : int; const s : unit) : list (operation) * unit is
|
2020-02-05 08:27:56 +04:00
|
|
|
block {
|
2020-02-26 21:31:58 +04:00
|
|
|
if p > 10 then failwith ("Failure.") else skip
|
2020-02-05 08:27:56 +04:00
|
|
|
}
|
2020-02-26 21:31:58 +04:00
|
|
|
with ((nil : list (operation)), s)
|
2020-02-05 08:27:56 +04:00
|
|
|
```
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="cameligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```cameligo
|
2020-02-26 21:31:58 +04:00
|
|
|
let main (p,s : int * unit) = if p > 10 then failwith "Failure."
|
2020-02-05 08:27:56 +04:00
|
|
|
```
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="reasonligo">
|
|
|
|
|
2020-02-05 08:27:56 +04:00
|
|
|
```reasonligo
|
2020-02-26 21:31:58 +04:00
|
|
|
let main = ((p,s) : (int, unit)) =>
|
|
|
|
if (p > 10) { failwith ("Failure."); };
|
2020-02-05 08:27:56 +04:00
|
|
|
```
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
|