Clarity Runtime for JavaScript
Acknowledgments
We thank Arweave and Blockstack for sponsoring the development of this project as part of the development of Sworn.
Status
Mapping of Clarity types
Clarity | TypeScript | JavaScript | Notes |
---|---|---|---|
bool |
boolean |
boolean |
|
(buff N) |
Uint8Array |
Uint8Array |
|
err |
Err<T> |
Err |
|
int |
number or bigint
|
number or BigInt
|
|
(list N T) |
Array<T> |
Array |
|
(optional T) |
T or null
|
T or null
|
|
principal |
String |
String |
|
(response T E) |
T or Err<E>
|
T or Err
|
|
(string-ascii N) |
String |
String |
|
(string-utf8 N) |
String |
String |
|
(tuple ...) |
Map<String, any> |
Map |
|
uint |
number or bigint
|
number or BigInt
|
Supported Clarity features
Clarity | Type | TypeScript | Status | Notes |
---|---|---|---|---|
* |
function | mul() |
||
+ |
function | add() |
||
- |
function | sub() |
||
/ |
function | div() |
||
< |
function | lt<T>() |
||
<= |
function | le<T>() |
||
> |
function | gt<T>() |
||
>= |
function | ge<T>() |
||
append |
function | append() |
||
as-contract |
syntax | asContract<A>() |
ⓐ | |
as-max-len? |
syntax | asMaxLen<T>() |
||
at-block |
syntax | atBlock<A>() |
Not supported by SmartWeave. | |
block-height |
keyword | blockHeight() |
ⓐ | |
concat |
function | concat() |
||
contract-call? |
function | contractCall<A, B>() |
Not supported by SmartWeave. | |
contract-caller |
keyword | contractCaller() |
ⓐ | |
contract-of |
function | contractOf() |
Not supported by SmartWeave. | |
default-to |
function | defaultTo<T>() |
||
err |
function | err<T() |
||
filter |
function | filter<A>() |
||
fold |
function | fold<A, B>() |
||
ft-get-balance |
function | ftGetBalance() |
||
ft-mint? |
function | ftMint() |
||
ft-transfer? |
function | ftTransfer() |
||
get |
function | get<T>() |
||
get-block-info? |
function | getBlockInfo() |
Not supported by SmartWeave. | |
hash160 |
function | hash160() |
||
is-eq |
function | isEq() |
||
is-err |
function | isErr() |
||
is-none |
function | isNone() |
||
is-ok |
function | isOk() |
||
is-some |
function | isSome() |
||
keccak256 |
function | keccak256() |
||
len |
function | len<T>() |
||
list |
function | list<T>() |
||
map |
function | map<A, B>() |
||
map-delete |
function | mapDelete() |
||
map-get? |
function | mapGet() |
||
map-insert |
function | mapInsert() |
||
map-set |
function | mapSet() |
||
match |
syntax | match<T, E>() |
||
mod |
function | mod() |
||
nft-get-owner? |
function | nftGetOwner() |
||
nft-mint? |
function | nftMint() |
||
nft-transfer? |
function | nftTransfer() |
||
none |
constant | none |
||
not |
function | not() |
||
ok |
function | ok<T, E>() |
||
pow |
function | pow() |
||
print |
function | print<T>() |
||
sha256 |
function | sha256() |
||
sha512 |
function | sha512() |
||
sha512/256 |
function | sha512_256() |
||
some |
function | some() |
||
to-int |
function | toInt() |
||
to-uint |
function | toUint() |
||
try! |
syntax | tryUnwrap<A, B>() |
||
tuple |
function | tuple() |
||
tx-sender |
keyword | txSender() |
ⓐ | |
unwrap! |
syntax | unwrap<A, B>() |
||
unwrap-err! |
syntax | unwrapErr<A, B>() |
||
unwrap-err-panic |
function | unwrapErrPanic<A, B>() |
||
unwrap-panic |
function | unwrapPanic<A, B>() |
||
xor |
function | xor() |
Legend: