A browser friendly implementation of CLVM in TypeScript, based off of the Chia Network implementation written in Python.
Chialisp is an on-chain smart coin programming language developed by the Chia Network. It is compiled and then executed by the Chialisp Virtual Machine, or CLVM for short.
This particular implementation is written with TypeScript, and is not bindings to native code. This allows it to be used in the browser as well. However, if you prefer native bindings, you should check out this library instead.
You can learn more about how this language works here. This is a implementation and should work as expected, but in any case that it differs, please open an issue.
By design, the functions and methods exposed by this library are synchronous and everything is exported for ease of use.
Since it is written in TypeScript, there are built-in typings for IntelliSense. The following documentation is non-exhaustive, but should be enough for most uses.
Either Cons
or Uint8Array
.
A tuple of Program
and Program
.
This represents a program or value in Chialisp or compiled clvm. It is the main class of the library, allowing you to manipulate programs and convert between various forms.
- A program representing the value
1
.
- A program representing the value
()
.
- The
Uint8Array
value of the program.
- The
Cons
pair of the program.
- The first
Program
value ofcons
.
- The rest
Program
value ofcons
.
- A
boolean
for if it's an atom.
- A
boolean
for if it's a cons pair.
- A
boolean
for if it's null.
first
is aProgram
.rest
is aProgram
.- Returns a
Program
that is a cons pair between them.
bytes
is aUint8Array
.- Returns a
Program
.
hex
is a hexstring
.- Returns a
Program
.
value
is aboolean
.- Returns a
Program
.
value
is anumber
.- Returns a
Program
.
value
is abigint
.- Returns a
Program
.
text
is astring
.- Returns a
Program
.
source
is astring
.- Returns a
Program
.
programs
is anArray<Program>
.- Returns a
Program
.
bytes
is aUint8Array
.- Returns a
Program
.
value
is aValue
.
- A
string
containing the line and column suffix, if there is one.
position
is aPosition
.- Returns
this
.
args
is anArray<Program>
.- Returns a
Program
containing the current one with each argument applied to it in reverse, precommitting them in the final solution.
- Returns a
[Program, Array<Program>]
containing the mod and curried in arguments.
- Returns a
Uint8Array
of the tree hash of the program. Hashed with1
for atoms, and2
for cons pairs.
- Returns a hex
string
representation of the tree hash.
- Returns a
Program
containing the current one wrapped in a mod if there isn't already, and with a definition inserted.
programs
is anArray<Program>
.- Returns a
Program
containing the current one and each definition.
options
is a partialCompileOptions
, defaulting tostrict = false
,operators = base
, andincludeFilePaths = {}
.- Returns a
ProgramOutput
that is the result of compiling the program. Should be identical to therun
CLI tool.
environment
is aProgram
.options
is a partialRunOptions
, defaulting tostrict = false
andoperators = base
.- Returns a
ProgramOutput
that is the result of running the program. Should be identical to thebrun
CLI tool.
- Returns a
Uint8Array
representation.
- Returns a hex
string
representation.
- Returns a
boolean
representation.
- Returns a
number
representation.
- Returns a
bigint
representation.
- Returns a
string
representation.
showKeywords
is aboolean
, by defaulttrue
.- Returns a
string
source code representation, like it would be if it were an output fromrun
orbrun
.
strict
is aboolean
, by defaultfalse
.- Returns an
Array<Program>
representation. If it's strict, it must be a proper list.
- Returns a
Uint8Array
serialized form of the program.
- Returns a hex
string
representation of the serialized form of the program.
value
is aProgram
.- Returns a
boolean
for if the values are exactly equal.
- Returns a
string
source code representation, like it would be if it were an output fromrun
orbrun
.