Data within a smart contract’s data-space is stored within
To get or set a value in a map you use:
(map-get map-name key-tuple)— This fetches the value associated with a given key in the map, or returns
noneif there is no such value.
(map-set! map-name key-tuple value-tuple)— This will set the value of
key-tuplein the data map
(map-insert! map-name key-tuple value-tuple)— This will set the value of
key-tuplein the data map if and only if an entry does not already exist.
(map-delete! map-name key-tuple)— This will delete
key-tuplefrom the data map.
A smart contract defines the data schema of a data map through
Clarity is a strongly-typed language. Its type system has the following types:
(tuple (key-name-0 key-type-0) (key-name-1 key-type-1) ...)— a typed tuple with named fields.
(list max-len entry-type)— a list of maximum length
max-len, with entries of type
(response ok-type err-type)— used by public functions to commit their changes or abort.
(optional some-type)— an option type for objects that can either be
principal— object representing a principal. A principal represents the address on the blockchain. There are two types of principals; standard principal (has private key) and contract principal (points to a smart contract).
bool— boolean value (
int— signed 128-bit integer
uint— unsigned 128-bit integer