• Stars
    star
    572
  • Rank 75,298 (Top 2 %)
  • Language
    Haskell
  • License
    BSD 3-Clause "New...
  • Created over 7 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The Pact Smart Contract Language

Kadena

Β 

The Pact Programming Language

Build Status

Pact is an open-source, Turing-incomplete smart contract language that has been purpose-built with blockchains first in mind. Pact focuses on facilitating transactional logic with the optimal mix of functionality in authorization, data management, and workflow.

Read the whitepaper:

For additional information, press, and development inquiries, please refer to the Kadena website

Table Of Contents

Tutorials

Extensive tutorials on every facet of the Pact language may be found on docs.kadena.io. Additionally, users may find example scripts in Kadena's pact-examples repository, in the examples directory, and in production as part of the Kadena Public Blockchain.

Documentation

The Pact language specification, API documentation, features, motivations, and in-depth tutorial content may be found here.

Documentation is always in flux, and corrections to out of date documentation are always appreciated. Feel free to do so if you find such an error by opening an issue.

Quickstart

The easiest and quickest way to try Pact is in the browser, or via the Chainweaver wallet. Both environments support error and warning highlighting, as well as an in-app REPL environment for you to test out your code immediately. The Kadena docs also include a developer quickstart.

Installing Pact

Binary Downloads

Pact can be installed via ready-to-use binary downloads for Linux or Mac by following the instructions below:

  • Install z3 >= 4.11.2.
  • Download the prebuilt binaries for either Linux or Mac, depending on your OS.
  • Once you've downloaded the binary, make sure that it is marked as executable by running chmod +x <executable-file>.
  • Put the binary somewhere in your PATH.

Once you have Pact in your path, proceed to validating your installation by trying out the repl.

Instructions for Mac Users

Using Brew

On Mac, the easiest way to install pact is with Homebrew. Make sure that Homebrew has been installed in your machine. Instructions for how to install it can be found here. Once Homebrew is installed, run the following command to install pact:

brew update
brew install kadena-io/pact/pact

If you want to install from source, see building from source

Instructions for Linux Users

Linux is supported both in terms of ready-to-use binary downloads (see Binary Downloads) and building from source. For installing pact on Linux distributions in the Arch family, refer to this package on the AUR. Otherwise, please refer to building from source.

Building from Source

Dependencies

  • (Mac only) Homebrew: brew install git
  • (Linux/Mac) Installer

To get the code, you can go here. Once you have the code, we can pick a build tool.

Building with Cabal

Cabal is the preferred way to manage packages by the Haskell community. You will need a version of GHC installed on your machine to use it.

Dependencies
  • ghc >= 8.4 (Haskell compiler) and cabal >= 2.2 (Haskell build-tool)
    • The easiest way to get this is to install it using (Linux/Mac) ghcup and issue ghcup install 8.6.5, followed by ghcup install-cabal.
    • ghc may also be installed via brew, issuing brew install ghc and brew install cabal-install.

(You may also need to install zlib, z3, and sqlite)

To build a Pact binary:

# Only necessary if you haven't done this recently.
cabal v2-update

# Build the project.
cabal v2-build

On some systems the default build might fail with linker errors complaining about cryptonite and ed25519, try:

# configure cabal 
cabal v2-configure -f cryptonite-ed25519

# Build the project.
cabal v2-build

This will install a runnable version of Pact, which you can run via:

cabal v2-exec pact

Alternatively, running cabal v2-install exe:pact inside this repository's root will install the binary to ~/.cabal/bin/, which you may need to add to your path. Then, you can call pact as-is.

Building with Nix

The fastest way to build and run Pact is to use the Nix package manager which has binary caching capabilities that allow you to download pre-built binaries for everything needed by Pact. For detailed instructions see our wiki.

When the build is finished, you can run Pact with the following command:

./result/ghc/pact/bin/pact

Verifying Installation

Test by issuing pact in a terminal or by executing your binary. Try out some commands:

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

Supported Editors

Pact is supported by a variety of editors ranging from full-fledged IDE environments to syntax highlighting. Moreover, we also provide a Pact Language Server, which can be seamlessly integrated with a wide range of editors. The Pact Language Server can be found here.

Chainweaver

The Chainweaver wallet is the Kadena's wallet, offering a seamless IDE experience and wallet in one. It supports a full in-app REPL, code preview, error/warning highlighting, code deployment, key generation, and integration with existing Kadena blockchains.

In-Browser

An implementation of Chainweaver exists in the browser, if you do not wish to download the wallet.

Atom

For a full-fledged IDE experience, install the Atom editor along with language-pact using the atom package manager.

VS Code

The Pact language has community support for VS Code via the pact-vscode package. (https://github.com/kadena-community/pact-vscode)

Emacs

Emacs has pact-mode support via MELPA, along with flycheck-pact for on-the-fly error highlighting. Download pact-mode and (optionally) flycheck-pact by opening Emacs and issuing M-x package-list-packages, syncing MELPA, and installing by name. Then, in your init.el or .emacs, include

(use-package pact-mode
  :ensure t
  :config
  ;; optionally
  (require 'flycheck-pact))

If you've chosen to include flycheck-pact, you can start the interactive buffer and trace by calling flycheck-pact-toggle-trace and flycheck-pact-interactive-buffer.

Vim

If you are a vim user, the vim-pact plugin provides support for the pact syntax.

The Pact REST Api

Api Documentation

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

Pact REST API Server

Pact 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.

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:

console> 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.

Related Projects

  • The pact-lang-api npm package provides a JavaScript library to aid interaction with the API.

  • The pact-todomvc is a working demonstration.

License

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

More Repositories

1

juno

Smart Contracts Running on a BFT Hardened Raft
Haskell
453
star
2

chainweb-node

Chainweb: A Proof-of-Work Parallel-Chain Architecture for Massive Throughput
Haskell
238
star
3

chainweaver

Kadena Chainweaver desktop wallet and web-based playground for Pact
Haskell
59
star
4

masala

Standalone Ethereum Virtual Machine
Haskell
51
star
5

chainweb-mining-client

A mining client for Kadena
Haskell
43
star
6

kadenaswap

Kadenaswap, a multi-protocol, scalable DEX
JavaScript
35
star
7

chainweb-miner

Official mining software for the Kadena Public Blockchain.
Haskell
32
star
8

marmalade

Decentralized Infrastructure for Poly-Fungibles and NFTs
Pact
24
star
9

kadenamint

Haskell
21
star
10

pact-todomvc

Demo of integrating a JS webapp with the Pact smart contract langauge
JavaScript
21
star
11

pact-lang-api

JavaScript
20
star
12

create-pact-app

JavaScript
18
star
13

KIPs

Kadena Improvement Proposals
Pact
16
star
14

developer-scripts

JavaScript
15
star
15

kadena-docs

Documentation and announcements for miners on the Kadena Public Blockchain
HTML
12
star
16

chainweb-data

Data ingestion for Chainweb.
Haskell
12
star
17

technical-grants

Kadena Technical Grants
10
star
18

kda-tool

CLI interface to the the Kadena blockchain
Haskell
9
star
19

chainweb-cuda-miner

Chainweb mining code for CUDA
C++
8
star
20

pact-lsp

LSP server for the Pact language
Haskell
8
star
21

kuro

Kuro permissioned blockchain, powered by ScalableBFT and Pact
Haskell
7
star
22

block-explorer

Haskell
7
star
23

devnet

Ad-hoc local Kadena development network
Nix
7
star
24

pact-5

The New Pact
Haskell
7
star
25

digraph

Directed Graphs
Haskell
6
star
26

pact-examples

Examples of smart contracts in Pact
5
star
27

chainweb-stream

Streaming server for chainweb events
TypeScript
5
star
28

signing-api

Kadena wallet signing API definition and reference docs
Nix
5
star
29

merkle-log

Haskell Merkle Tree Logs
Haskell
5
star
30

docker-compose-chainweb-node

Docker compose setups for chainweb-node
4
star
31

pact-mode

Emacs Major Mode for the Pact smart contract language.
Emacs Lisp
4
star
32

pact-model

Modeling the Pact core language
Coq
4
star
33

chainweb-api

Common types for communicating with a Chainweb Node.
Haskell
4
star
34

pact-atom

Support for the Pact Smart Contract language in Atom
CoffeeScript
4
star
35

wallet-connect-example

Example repository on how to implement Kadena with Wallet Connect
TypeScript
4
star
36

pypact

Python package for interacting with Pact server
Python
3
star
37

chainweb-node-docker

Shell
3
star
38

merkle-log-rs

Binary Merkle Trees
Rust
3
star
39

peso-stablecoin

JavaScript
3
star
40

pact-manual

A user's guide and reference manual for the Pact smart contract language
Nix
3
star
41

pact-web-repl

A web-based REPL for the Pact smart contract language
Haskell
2
star
42

chainweb-openapi

OpenAPI Specification of the Chainweb Node API
HTML
2
star
43

kda-exchange-integration

JavaScript
2
star
44

KDA-to-ETH-Attestation

For the KDA to ETH leg of the bridge
JavaScript
2
star
45

ledger-app-kadena

Nix
2
star
46

kpkgs

Nix
2
star
47

pacty-parrots

TypeScript
2
star
48

setup-nix-with-cache

2
star
49

raspberrypi-blockchain

Read temperature and humidity from sensor and save to blockchain
Python
2
star
50

rosetta

Haskell
2
star
51

ipfs-pact-tutorial

JavaScript
2
star
52

kadena-ethereum-bridge

Support building bridges between Kadena and Ethereum
Haskell
2
star
53

flycheck-pact

Flycheck support for the Pact Smart Contract Language major mode
Emacs Lisp
2
star
54

txg

Chainweb Transaction Generator
Haskell
2
star
55

pact-lang.org-code

Pact-lang.org code examples
1
star
56

chainweb.js

Javascript bindings for the Kadena Chainweb API
JavaScript
1
star
57

covid19-platform

Repo for both platform frontends and shared pact smart contracts
JavaScript
1
star
58

tx-template

Command line tool for pact transaction templating
Haskell
1
star
59

streaming-events

Client-side consumption of a ServerEvent.
Haskell
1
star
60

dao.init-frontend

A front end for dao.init
JavaScript
1
star
61

chainweb-storage

key value stores for chainweb
Haskell
1
star
62

pact-json

JSON encoding for pact
Haskell
1
star
63

homebrew-pact

Homebrew tap for the Pact smart contract language interpreter
Ruby
1
star
64

hs-nix-infra

Common Nix setup and dependencies for Kadena's Haskell projects
Nix
1
star