Skip to main content

[Contract Language | Chialisp] Virtual Machine

Project description

This is the in-development version of a LISP-like language for encumbering and releasing funds with smart-contract capabilities.

See docs/clvm.org for more info.

Testing

$ pip install -e '.[dev]'
$ py.test tests

Example

Here's an example on how to create a script and invoke it from python.

$ python
>>> from clvm import to_sexp_f, run_program, KEYWORD_TO_ATOM
>>> program = to_sexp_f([KEYWORD_TO_ATOM["q"], 100])     # (q 100)
>>> args = to_sexp_f([])
>>> r = run_program(program, args)
>>> print(r.listp())
False
>>> print(r.as_int())
100
>>>
>>> program = to_sexp_f([KEYWORD_TO_ATOM["+"], [KEYWORD_TO_ATOM["q"], 500], \
...                     [KEYWORD_TO_ATOM["f"], [KEYWORD_TO_ATOM["a"]]]])     # (+ (q 500) (f (a)))
>>> args = to_sexp_f([25])   # (25)
>>> r = run_program(program, args)
>>> print(r.listp())
False
>>> print(r.as_int())
525
>>>
>>> program = to_sexp_f([KEYWORD_TO_ATOM["c"], \
...                     [KEYWORD_TO_ATOM["f"], [KEYWORD_TO_ATOM["r"], [KEYWORD_TO_ATOM["a"]]]], \
...                     [KEYWORD_TO_ATOM["f"], [KEYWORD_TO_ATOM["a"]]]])     # (c (f (r (a))) (f (a)))
>>> args = to_sexp_f([45, 55])
>>> r = run_program(program, args)
>>> print(r.listp())
True
>>> print(r.first().as_int())
55
>>> print(r.rest().as_int())
45

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for clvm, version 0.5.1
Filename, size File type Python version Upload date Hashes
Filename, size clvm-0.5.1-py3-none-any.whl (14.1 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page