Variables
Solidity has local, state, and global variables. Lithe has locals, two kinds of storage, and the Evm module.
variables.lithe
(* Three lifetimes: locals last for the call, transient storage for the
transaction, storage forever. *)
import "std/evm";
storage is record {
total : uint;
lastCaller : address;
}
transient storage is record {
callsThisTx : uint;
}
external function track(const amount : uint) is {
(* `const` is immutable. Every local binding names its type. *)
const caller : address := Evm.sender();
(* `var` can be reassigned with `:=`. *)
var bonus : uint := 0;
if amount > 100 then {
bonus := 1;
}
(* Contract state is always qualified: `storage.` or `transient.` *)
storage.total := storage.total + amount + bonus;
storage.lastCaller := caller;
transient.callsThisTx := transient.callsThisTx + 1;
}
(* Execution context comes from `Evm`, not magic globals. *)
external view function context() : (address, uint, timestamp) is
(Evm.sender(), Evm.blockNumber(), Evm.blockTimestamp())- Every local binding names its type:
const caller : address := .... There is no inference for bindings. transientstorage is cleared at the end of every transaction. See Transient storage.Evm.sender(),Evm.blockNumber(), and the rest of the context are listed in Built-ins.

