Learn Fi
  • Introduction
  • Overview
    • Contract Definitions
    • Basic Types
    • Complex Types
    • Control Structures
    • Local Variables
    • Functions
    • Type Casting
    • Variable Modifiers
    • Global Constants
    • Examples
Powered by GitBook
On this page

Was this helpful?

  1. Overview

Type Casting

Although fi types can be confusing, we've implement a number of typecasting functions to help ensure typing is clean and consistent.

to_address - converts a contract, key, pkh/key_hash to an address

to_int - converts mutez or nat to an int

to_mutez - converts nat or int to mutez

to_nat - converts mutez or int to nat

to_optional - converts any type to an optional version of that type

to_pkh - converts a key to a key_hash/pkh

to_some - converts an optional type to a normal type (throws an error if the value is an empty optional value)

to_contract - converts a key, pkh/key_hash or address to a contract unit. If a second type argument is provided, will type cast an address to a typed address of matching type.

PreviousFunctionsNextVariable Modifiers

Last updated 6 years ago

Was this helpful?