Skip to main content

chiklisp

GitHub Coverage Status Build Crate Build Wheels

PyPI Crates.io

Theory of operation of the modern compiler: ./HOW_CHIKLISP_IS_COMPILED.md

This repo can be installed via cargo

cargo install chiklisp

or via pip

pip install chiklisp@git+https://github.com/Chik-Network/klvm_tools_rs.git@e17412032aa7d3b8b1d1f931893fb5802eee626a

Note: pip installs a subset of the tools installed by cargo, including brun, run, opc and opd.

The most current version of the language is in the nightly branch:

[nightly](https://github.com/Chik-Network/chiklisp/tree/nightly)

To install from a specific branch:

cargo install --no-default-features --git 'https://github.com/Chik-Network/chiklisp' --branch nightly

To install a git checkout into your current python environment (must be in some kind of venv or conda environment):

git clone https://github.com/Chik-Network/chiklisp
cd chiklisp
maturin develop

Install from PYPI:

pip install -i https://pypi.chiknetwork.com/nightlies/ chiklisp

Most people still compile chiklisp via python. One way to set up compilation in that way is like this:

import json
from chiklisp import compile_klvm

def compile_module_with_symbols(include_paths,source):
    path_obj = Path(source)
    file_path = path_obj.parent
    file_stem = path_obj.stem
    target_file = file_path / (file_stem + ".klvm.hex")
    sym_file = file_path / (file_stem + ".sym")
    compile_result = compile_klvm(source, str(target_file.absolute()), include_paths, True)
    symbols = compile_result['symbols']
    if len(symbols) != 0:
        with open(str(sym_file.absolute()),'w') as symfile:
            symfile.write(json.dumps(symbols))

The command line tools provided:

- run -- Compiles KLVM code from chiklisp

Most commonly, you'll compile chiklisp like this:

  ./target/debug/run -O -i include_dir chiklisp.clsp

'run' outputs the code resulting from compiling the program, or an error.

- repl -- Accepts chiklisp forms and expressions and produces results
          interactively.
          
Run like:

  ./target/debug/repl
  
Example session:

>>> (defmacro assert items
   (if (r items)
       (list if (f items) (c assert (r items)) (q . (x)))
     (f items)
     )
   )
(q)
>>> (assert 1 1 "hello")
(q . hello)
>>> (assert 1 0 "bye")
failed: CompileErr(Srcloc { file: "*macros*", line: 2, col: 26, until: Some(Until { line: 2, col: 82 }) }, "klvm raise in (8) (())")
>>> 

- cldb -- Stepwise run chiklisp programs with program readable yaml output.

  ./target/debug/cldb '(mod (X) (x X))' '(4)'
  ---
  - Arguments: (() (4))
    Operator: "4"
    Operator-Location: "*command*(1):11"
    Result-Location: "*command*(1):11"
    Row: "0"
    Value: (() 4)
  - Env: "4"
    Env-Args: ()
    Operator: "2"
    Operator-Location: "*command*(1):11"
    Result-Location: "*command*(1):13"
    Row: "1"
    Value: "4"
  - Arguments: (4)
    Failure: klvm raise in (8 5) (() 4)
    Failure-Location: "*command*(1):11"
    Operator: "8"
    Operator-Location: "*command*(1):13"

- brun -- Runs a "binary" program.  Instead of serving as a chiklisp
  compiler, instead runs klvm programs.

As 'brun' from the python code:

$ ./target/debug/run '(mod (X) (defun fact (N X) (if (> 2 X) N (fact (* X N) (- X 1)))) (fact 1 X))'
(a (q 2 2 (c 2 (c (q . 1) (c 5 ())))) (c (q 2 (i (> (q . 2) 11) (q . 5) (q 2 2 (c 2 (c (* 11 5) (c (- 11 (q . 1)) ()))))) 1) 1))
$ ./target/debug/brun '(a (q 2 2 (c 2 (c (q . 1) (c 5 ())))) (c (q 2 (i (> (q . 2) 11) (q . 5) (q 2 2 (c 2 (c (* 11 5) (c (- 11 (q . 1)) ()))))) 1) 1))' '(5)'
120

- opc -- crush klvm s-expression form to hex.

As 'opc' from the python code.

opc '(a (q 2 2 (c 2 (c (q . 1) (c 5 ())))) (c (q 2 (i (> (q . 2) 11) (q . 5) (q 2 2 (c 2 (c (* 11 5) (c (- 11 (q . 1)) ()))))) 1) 1))'
ff02ffff01ff02ff02ffff04ff02ffff04ffff0101ffff04ff05ff8080808080ffff04ffff01ff02ffff03ffff15ffff0102ff0b80ffff0105ffff01ff02ff02ffff04ff02ffff04ffff12ff0bff0580ffff04ffff11ff0bffff010180ff808080808080ff0180ff018080

- opd -- disassemble hex to s-expression form.

As 'opd' from the python code.

opd 'ff02ffff01ff02ff02ffff04ff02ffff04ffff0101ffff04ff05ff8080808080ffff04ffff01ff02ffff03ffff15ffff0102ff0b80ffff0105ffff01ff02ff02ffff04ff02ffff04ffff12ff0bff0580ffff04ffff11ff0bffff010180ff808080808080ff0180ff018080'
(a (q 2 2 (c 2 (c (q . 1) (c 5 ())))) (c (q 2 (i (> (q . 2) 11) (q . 5) (q 2 2 (c 2 (c (* 11 5) (c (- 11 (q . 1)) ()))))) 1) 1))

History

This is a second-hand port of chik's klvm tools to rust via the work of ChikMineJP porting to typescript. This would have been a lot harder to get to where it is without prior work mapping out the types of various semi-dynamic things (thanks, ChikMineJP).

Some reasons for doing this are:

  • Chik switched the klvm implementation to rust: klvm_rs, and this code may both pick up speed and track klvm better being in the same language.

  • I wrote a new compiler with a simpler, less intricate structure that should be easier to improve and verify in the future in ocaml: ochiklisp.

  • Also it's faster even in this unoptimized form.

All acceptance tests i've brought over so far work, and more are being added. As of now, I'm not aware of anything that shouldn't be authentic when running these command line tools from klvm_tools in their equivalents in this repository

  • opc

  • opd

  • run

  • brun

  • repl

argparse was ported to javascript and I believe I have faithfully reproduced it as it is used in cmds, so command line parsing should work similarly in all three versions.

The directory structure is expected to be:

src/classic  <-- any ported code with heritage pointing back to
                 the original chik repo.
                
src/compiler <-- a newer compiler (ochiklisp) with a simpler
                 structure.  Select new style compilation by
                 including a `(include *standard-cl-21*)`
                 form in your toplevel `mod` form.

Mac M1

Use cargo build --no-default-features due to differences in how mac m1 and other platforms handle python extensions.

Use with chik-blockchain

# Activate your venv, then
$ maturin develop --release

Metadata

Release files for chiklisp 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chiklisp 0.4.1
File Size Uploaded
chiklisp-0.4.1.tar.gz 553.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for chiklisp 0.4.1
File
chiklisp-0.4.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
chiklisp-0.4.1-cp310-abi3-musllinux_1_1_x86_64.whl CPython 3.10 abi3 Linux musl 1.1+ x86-64 Details
chiklisp-0.4.1-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details
chiklisp-0.4.1-cp310-abi3-macosx_15_0_x86_64.whl CPython 3.10 abi3 macOS 15.0+ x86-64 Details
chiklisp-0.4.1-cp310-abi3-macosx_15_0_arm64.whl CPython 3.10 abi3 macOS 15.0+ ARM64 Details
chiklisp-0.4.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
chiklisp-0.4.1-cp39-abi3-musllinux_1_1_x86_64.whl CPython 3.9 abi3 Linux musl 1.1+ x86-64 Details
chiklisp-0.4.1-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details
chiklisp-0.4.1-cp39-abi3-manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64 Details
chiklisp-0.4.1-cp39-abi3-macosx_13_0_x86_64.whl CPython 3.9 abi3 macOS 13.0+ x86-64 Details
chiklisp-0.4.1-cp39-abi3-macosx_13_0_arm64.whl CPython 3.9 abi3 macOS 13.0+ ARM64 Details

Total release size: 16.5 MB

Release files / chiklisp-0.4.1.tar.gz

Download URL chiklisp-0.4.1.tar.gz
Size 553.0 kB
Tags Source
SHA-256 checksum
How to use checksums
dcc6da9ba5fd28f3b3245ec580f1b6a94f59d23d17865f53238b9e7a83eec9d9
BLAKE2b-256 checksum
How to use checksums
d02924edfa551ad14b43aae11a5ec6d759ecaba681abd614ea4fad533f128733
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / chiklisp-0.4.1-cp310-abi3-win_amd64.whl

Download URL chiklisp-0.4.1-cp310-abi3-win_amd64.whl
Size 1.4 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
9419ddc756a6772d595b51b031cba8953e03a31fb7025ef8b8dde5c44f4e655c
BLAKE2b-256 checksum
How to use checksums
2c5143f9d45cb89d0e2d822fc483bf9f5f8814a0b973effad57ca94934564817
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / chiklisp-0.4.1-cp310-abi3-musllinux_1_1_x86_64.whl

Download URL chiklisp-0.4.1-cp310-abi3-musllinux_1_1_x86_64.whl
Size 1.6 MB
Tags CPython 3.10 Linux musl 1.1+ x86-64 abi3
SHA-256 checksum
How to use checksums
bf741ca95325e17e61f7fd5b0c3a45a92135f6f8f4aa199f386dfa5f81d46ca5
BLAKE2b-256 checksum
How to use checksums
2eb81d0bb1f7a077042800f5b2aa413f8c7879f7517f7fbf071811e98521a413
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / chiklisp-0.4.1-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL chiklisp-0.4.1-cp310-abi3-manylinux_2_28_x86_64.whl
Size 1.5 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
069859e8a16e4b2ff23a45772108f3ef3d748753264777f08afcff9353df4214
BLAKE2b-256 checksum
How to use checksums
884b00784016f4842f82fb4bbc9c403d7ae65b41eb34804d2f91c8b53114a12a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / chiklisp-0.4.1-cp310-abi3-macosx_15_0_x86_64.whl

Download URL chiklisp-0.4.1-cp310-abi3-macosx_15_0_x86_64.whl
Size 1.4 MB
Tags CPython 3.10 abi3 macOS 15.0+ x86-64
SHA-256 checksum
How to use checksums
180586e72412ec97871c5c7dfded46827c6189d9ce609b1247273a6b7bd61ae9
BLAKE2b-256 checksum
How to use checksums
862c2c4d250d6633060d78c56962fc70e57c7e6a5b04c607eba4285a824188a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / chiklisp-0.4.1-cp310-abi3-macosx_15_0_arm64.whl

Download URL chiklisp-0.4.1-cp310-abi3-macosx_15_0_arm64.whl
Size 1.3 MB
Tags CPython 3.10 abi3 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
71765667239da825c226d8ee7ea1b23123f8de5fc4af48e65112bf160a787e9b
BLAKE2b-256 checksum
How to use checksums
30874be38fb9bcf546672ed160b85757430db7b652e29a7bdf6e4ad01ae86774
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / chiklisp-0.4.1-cp39-abi3-win_amd64.whl

Download URL chiklisp-0.4.1-cp39-abi3-win_amd64.whl
Size 1.4 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
290928f94092a939f6a485a5ec44454aabc18bbbdf4c34edc3203b1f367e933f
BLAKE2b-256 checksum
How to use checksums
b7c11a524e6b121d8ce45846a2b465c9d348212c100118b1226eadd1df563350
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / chiklisp-0.4.1-cp39-abi3-musllinux_1_1_x86_64.whl

Download URL chiklisp-0.4.1-cp39-abi3-musllinux_1_1_x86_64.whl
Size 1.6 MB
Tags CPython 3.9 Linux musl 1.1+ x86-64 abi3
SHA-256 checksum
How to use checksums
eca7f3fb28b36b6d6190877ac0471a3315b88a9d32a13871b599e4ac996d21a9
BLAKE2b-256 checksum
How to use checksums
968db7bb13ea4525308cb589c2cbc44446f65a426c29a685bfbb6c786e779f1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / chiklisp-0.4.1-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL chiklisp-0.4.1-cp39-abi3-manylinux_2_28_x86_64.whl
Size 1.5 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
729ab5537c58c47eeacd5017063d016cbf1f1dc88991ace514e3ec918870ca02
BLAKE2b-256 checksum
How to use checksums
4c603b8e918a4ca06bff7146c513342539e3699f73a01a33ff5ce7583a0a6db4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / chiklisp-0.4.1-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL chiklisp-0.4.1-cp39-abi3-manylinux_2_28_aarch64.whl
Size 1.5 MB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
a8b2c0a2f65d0838d0668f095030cc368b75d479e97158e602558bc42f0bc1f8
BLAKE2b-256 checksum
How to use checksums
45c6f4459ee5d851781a134eb1ea0b8189cdf787a04ba91e6cb1ca99bc71aa64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / chiklisp-0.4.1-cp39-abi3-macosx_13_0_x86_64.whl

Download URL chiklisp-0.4.1-cp39-abi3-macosx_13_0_x86_64.whl
Size 1.4 MB
Tags CPython 3.9 abi3 macOS 13.0+ x86-64
SHA-256 checksum
How to use checksums
9b5ab0f7c26a654101b5b184804e35b42ad44f153d6351d1969c6ee7c2682dbd
BLAKE2b-256 checksum
How to use checksums
aec294484961b9b12d7955d5139b9804d0de8df6a231e6a045d9183bb4d813ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / chiklisp-0.4.1-cp39-abi3-macosx_13_0_arm64.whl

Download URL chiklisp-0.4.1-cp39-abi3-macosx_13_0_arm64.whl
Size 1.3 MB
Tags CPython 3.9 abi3 macOS 13.0+ ARM64
SHA-256 checksum
How to use checksums
2ab143fd65d881e2a2be0dc18b35d1e1b85e23c5eb654dfebeddca292b7e4445
BLAKE2b-256 checksum
How to use checksums
2617eae9df1c83c3caacad985c9d9fa0754ba802abe8472953eac07341b62dac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release history Release notifications | RSS feed

0.6.0

7 release files

0.5.1

7 release files

0.5.0

7 release files

0.4.6

7 release files

0.4.5

7 release files

0.4.4

7 release files

0.4.3

7 release files

This release

0.4.1 This release

12 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page