Types
Singleton Types​
nat​
Naturals are arbitrary-precision, meaning that the only size limit is gas.
const { TNat } = require('@tezwell/smartts-sdk');
const type = TNat();
int​
Integers are arbitrary-precision, meaning that the only size limit is gas.
const { TInt } = require('@tezwell/smartts-sdk');
const type = TInt();
mutez​
Mutez (micro-Tez) are internally represented by 64-bit signed integers. These are restricted to prevent creating a negative amount of mutez.
const { TMutez } = require('@tezwell/smartts-sdk');
const type = TMutez();
string​
The current version of Michelson restricts strings to be the printable subset of 7-bit ASCII, namely characters with codes from within [32, 126] range, plus the following escape characters \n
, \\
, \"
.
const { TString } = require('@tezwell/smartts-sdk');
const type = TString();
bool​
The type for booleans whose values are True
and False
.
const { TBool } = require('@tezwell/smartts-sdk');
const type = TBool();
bytes​
Bytes are used for serializing data, in order to check signatures and compute hashes on them. They can also be used to incorporate data from the wild and untyped outside world.
const { TBytes } = require('@tezwell/smartts-sdk');
const type = TBytes();
address​
The type address
gives the guarantee that the value has the form of a Tezos address, as opposed to contract that guarantees that the value is indeed a valid, existing account.
A valid Tezos address is a string prefixed by either tz1
, tz2
, tz3
or KT1
and followed by a Base58 encoded hash and terminated by a 4-byte checksum.
The prefix designates the type of address:
tz1
addresses are followed by a ed25519 public key hashtz2
addresses are followed by a Secp256k1 public key hashtz3
addresses are followed by a NIST p256r1 public key hashKT1
addresses are followed by a contract hash
Addresses prefixed by tz1, tz2 and tz3 designate implicit accounts, whereas those prefixed KT1 designate originated accounts.
Addresses can also specify an entrypoint, with a %<entrypoint_name>
suffix.
const { TAddress } = require('@tezwell/smartts-sdk');
const type = TAddress();
timestamp​
The type timestamp
is used to represent timestamps that are written as the number of seconds since Epoch.
const { TTimestamp } = require('@tezwell/smartts-sdk');
const type = TTimestamp();
chain_id​
The type chain_id
represents an identifier for a chain, used to distinguish the test and the main chains.
const { TChain_id } = require('@tezwell/smartts-sdk');
const type = TChain_id();
bls12_381_fr​
The type bls12_381_fr
represents an element of the scalar field Fr, used for scalar multiplication on the BLS12-381 curves G1 and G2.
const { TBls12_381_fr } = require('@tezwell/smartts-sdk');
const type = TBls12_381_fr();
bls12_381_g1​
The type bls12_381_g1
represents a point on the BLS12-381 curve G1.
const { TBls12_381_g1 } = require('@tezwell/smartts-sdk');
const type = TBls12_381_g1();
bls12_381_g2​
The type bls12_381_g2
represents a point on the BLS12-381 curve G2.
const { TBls12_381_g2 } = require('@tezwell/smartts-sdk');
const type = TBls12_381_g2();
key​
The type key
represents a public cryptographic key.
const { TKey } = require('@tezwell/smartts-sdk');
const type = TKey();
key_hash​
The type key_hash
represents a hash of a public cryptographic key.
const { TKey_hash } = require('@tezwell/smartts-sdk');
const type = TKey_hash();
signature​
The type signature
represents a cryptographic signature.
const { TSignature } = require('@tezwell/smartts-sdk');
const type = TSignature();
unit​
The type whose only value is Unit, to use as a placeholder when some result or parameter is non-necessary.
const { TUnit } = require('@tezwell/smartts-sdk');
const type = TUnit();
operation​
The type operation
represents an internal operation emitted by a contract.
const { TOperation } = require('@tezwell/smartts-sdk');
const type = TOperation();
never​
The type never
is used to represent an unreachable branch.
const { TNever } = require('@tezwell/smartts-sdk');
const type = TNever();
Container types​
list​
The list
type reprensents a immutable and homogeneous linked list.
const { TList, TNat } = require('@tezwell/smartts-sdk');
const type = TList(TNat());
set​
The set
type is used to represent sequences of unique elements.
const { TSet, TNat } = require('@tezwell/smartts-sdk');
const type = TSet(TNat());
option​
The option
type is used to represent an optional value.
const { TOption, TNat } = require('@tezwell/smartts-sdk');
const type = TOption(TNat());
pair​
The pair
type represents a binary tuple composed of a left element and a right element.
const { TPair, TNat, TString } = require('@tezwell/smartts-sdk');
const type = TPair(TString(), TNat());
or​
The type or
represents a union of two types. Used for type variance. (e.g. number | string)
const { TOr, TNat, TString } = require('@tezwell/smartts-sdk');
const type = TOr(TString(), TNat());
map​
const { TMap, TNat, TString } = require('@tezwell/smartts-sdk');
const type = TMap(TString(), TNat());
big_map​
The type big_map
is used to represent lazily deserialized maps.
const { TBigMap, TNat, TString } = require('@tezwell/smartts-sdk');
const type = TBigMap(TString(), TNat());
lambda​
The type lambda
represents a function signature.
const { TLambda, TNat, TString } = require('@tezwell/smartts-sdk');
const type = TLambda(TString(), TNat());
ticket​
The type ticket
represents a ticket used to authenticate information.
const { TTicket, TString } = require('@tezwell/smartts-sdk');
const type = TTicket(TString());
contract​
The type contract
represents the interface and address of a contract entrypoint.
const { TContract, TString } = require('@tezwell/smartts-sdk');
const type = TContract(TString());
sapling_state​
Michelson reference sapling_state.
const { TSapling_state } = require('@tezwell/smartts-sdk');
const type = TSapling_state(8);
sapling_transaction​
Michelson reference sapling_transaction.
const { TSapling_transaction } = require('@tezwell/smartts-sdk');
const type = TSapling_transaction(8);
Artificial types​
record​
A TRecord
is an artificial type composed of nested pair's
with annotated leaves to simulate a dictionary.
const { TRecord, TNat, TInt, TBytes } = require('@tezwell/smartts-sdk');
const type = TRecord(
{
field1: TNat(),
field2: TInt(),
field3: TBytes()
},
// Optional argument (defaults to right combs)
["field1", ["field2", "field3"]]
);
variant​
A TVariant
is an artificial type composed of nested or's
with annotated leaves to create a union type.
const { TVariant, TNat, TInt, TBytes } = require('@tezwell/smartts-sdk');
const type = TVariant(
{
branch1: TNat(),
branch2: TInt(),
branch3: TBytes()
},
// Optional argument (defaults to right combs)
["branch1", ["branch2", "branch3"]]
);