Skip to content
LogoLogo

Visibility

external functions form the contract's ABI. Everything else is internal. private hides a declaration from files that import this one.

visibility.lithe
(* `external` functions are the contract's ABI. They cannot call each other; share
   logic through internal functions instead. Internal functions are callable
   from anywhere in the program. `private` hides a declaration from importing files. *)
 
storage is record {
  value : uint;
}
 
private pure function double(const n : uint) : uint is
  n * 2
 
function store(const n : uint) is {
  storage.value := double(n);
}
 
external function set(const n : uint) is {
  store(n);
}
 
external function setTwice(const n : uint) is {
  store(n);
  store(storage.value);
}
 
external view function get() : uint is
  storage.value

Calling an external function from inside the contract is an error:

external function `set` cannot be called from inside the contract; move the shared logic into an internal function