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.

Last updated