Haskell C JavaScript Other
slpopejoy Merge pull request #163 from kadena-io/feat/improve-cp-example
Improve cp example and provide load scripts
Latest commit ed62cc0 Jul 22, 2018
Permalink
Failed to load latest commit information.
docs Gas model implementation with simple fixed-rate model Jul 2, 2018
examples Improve cp example and provide load scripts Jul 19, 2018
executables Close to working with slimmed down set of changes May 7, 2018
log added pact serve to command line Feb 9, 2017
pact-lang-api.js Privacy API first version done! May 3, 2017
src-ghc/Pact Break up Lang and Runtime types files Jul 7, 2018
src Fix object equality typecheck failure Jul 20, 2018
tests Fix object equality typecheck failure Jul 20, 2018
web Dep versions widened for both GHCJS and normal build; test passing Nov 5, 2017
.gitignore 2.4.0: Changelog and docs incorporate property stuff Jun 1, 2018
.travis.yml Add Pact property checker May 10, 2018
.weeder.yaml Some cleanup from Weeder run and weeder config file Mar 14, 2018
CHANGELOG.md 2.4.1 prep; add verified-accounts to tests regression Jun 4, 2018
HLint.hs Move hlint into tests, get it passing Apr 12, 2018
LICENSE simple command construction finished Feb 9, 2017
README.md Add stack-nix.yaml and description of nix incremental builds Jun 19, 2018
Setup.hs Pact open-source release Nov 13, 2016
appveyor.yml Add appveyor config. Feb 21, 2018
config.yaml No caching in SQLite layer, txid in beginTx, tx validation Feb 13, 2017
default.nix Update sbv rev and sha in default.nix Jul 12, 2018
pact.cabal Merge remote-tracking branch 'origin/master' into analyze Jul 13, 2018
repl.sh Pact open-source release Nov 13, 2016
stack-ghcjs.yaml Upgrade thyme for #6, document formats, 2.3.6 release prep Dec 13, 2017
stack-nix.yaml Add stack-nix.yaml and description of nix incremental builds Jun 19, 2018
stack.yaml Move to latest sbv with a local legacy SFunArray Jul 12, 2018

README.md

The Pact Programming Language

Build Status

This is the source code repository for Pact, a language for developing smart contracts to run on a fast deterministic blockchain.

References

Pact Homepage

Pact Reference Docs

Pact Whitepaper

Quick Start: Browser

The easiest way to try Pact is in the browser.

Quick Start: Atom

To start writing smart contracts, the best way to go is to use the Atom editor and install language-pact using the package manager.

Installing Pact with homebrew (OSX only)

You'll then need to install the Pact interpreter/REPL. On Mac, the easiest way is with homebrew.

brew install kadena-io/pact/pact

Installing Pact with Binary Distributions

Prebuilt binaries are available, or see building below.

Once you have downloaded the binary, put it somewhere in your PATH.

Verifying Install

Test by issuing pact in a terminal. Try out some commands:

$ pact
pact> (+ 1 2)
3
pact> (+ "hello, " "world")
"hello, world"

There are examples in this source repository of working smart contracts which you can load into Atom to get started.

Quick Start: Pact REST API Server

Pact now features a full REST API HTTP server and SQLite database implementation, making blockchain application development painless and easy. The Pact server simulates a single-node blockchain environment, with the same API supported by the Kadena ScalableBFT blockchain.

To start the server, issue pact --serve CONFIG or pact -s CONFIG, where CONFIG is a valid config.yaml.

REST API Docs

The REST API is documented at http://pact-language.readthedocs.io/en/latest/pact-reference.html#rest-api.

Related Projects

Hosting static files.

The HTTP server will host any static files it finds in its working directory.

Config file format

The pact dev server (pact-serve) requires a configuration Yaml file (e.g. server.conf) to operate. The documentation for it is:

➜  pact git:(feat/dev-server) pact --serve --help
Config file is YAML format with the following properties:
port       - HTTP server port
persistDir - Directory for database files.
             If ommitted, runs in-memory only.
logDir     - Directory for HTTP logs
pragmas    - SQLite pragmas to use with persistence DBs
verbose    - [True|False] Provide extra logging information

Replay from disk.

When running pact-serve with persistence enabled, the server automatically replays from the database commands.sqlite in the persist dir. To prevent replay, simply delete this file before starting the server.

Building

To build, you'll need a working Haskell Stack install . After which, building is as simple as 'stack build'.

To install for use with Atom and the command line, issue 'stack install' and then either add $HOME/.local/bin to your path, or symlink $HOME/.local/bin/pact somewhere in your PATH.

Building with Nix / NixOS

  1. Go to https://nixos.org/nix/, click "Get Nix", follow the instructions to install the Nix package manager
  2. Edit $NIX_CONF_DIR/nix.conf
  3. Set the binary-caches and binary-cache-public-keys lines as follows:
binary-caches = https://pact.cachix.org https://nixcache.reflex-frp.org https://cache.nixos.org/
binary-cache-public-keys = pact.cachix.org-1:cg1bsryGrHnQzqEp52NcHq4mBBL+R25XbR2Q/I/vQ8Y= ryantrinkle.com-1:JJiAKaRv9mWgpVAz8dwewnZe0AzzEAzPkagE9SP5NWI= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
  1. Restart the nix daemon.

On mac:

sudo launchctl stop org.nixos.nix-daemon
sudo launchctl start org.nixos.nix-daemon

On linux:

sudo systemctl restart nix-daemon.service
  1. Run nix-build from the project root

Incremental Builds

Building with nix-build does a full rebuild every time, which is usually not what you want when developing. To do incremental builds, you need to enter a nix shell. To do that use the following command:

$ nix-shell -A shells.ghc

This puts you in a shell that has all the necessary dependencies installed. Once inside this shell you can build as normal with cabal using cabal build or cabal new-build.

You can also build with stack inside this shell as follows:

$ stack --stack-yaml stack-nix.yaml build

License

This code is distributed under the terms of the BSD3 license. See LICENSE for details.