Getting started with Pact on your local device allows you to work in a powerful development environment to run your smart contracts locally. This environment can be set up on Mac, Windows, and Linux operating systems.

This tutorial will go over the details of getting up and running on a Mac operating system.

Windows and Linux Users

More instructions on installing Pact with Windows or Linux can be found on the GitHub page.

The terminal is helpful, but you’ll often want to create larger programs from within your editor.

The best way to write smart contracts locally is by using the Atom editor. Pact provides Atom integration giving you syntax highlighting, continuous integration with a directory, .repl scripts, and errors/warnings linting.

This clones a directory with many Pact examples. For now, navigate to the Hello World example.

cd pact-examples/hello-world

From within this folder, open the Pact terminal.

pact
pact>

Using the Pact terminal, run the hello-world.repl file.

(load "hello-world.repl")

Note

The .repl file loads the smart contract from the .pact file to run the code. This file contains the code behind the Load into REPL feature that has so far been available automatically from the online editor allowing you to run code locally. The contents of this .repl file are explained in more detail in the next tutorial.

After running this file, you should see the following output to your terminal.

You can check the contents of this smart contract by opening it in Atom.

First, exit the Pact terminal (or open a new terminal in this directory)

Press Control + D to exit the Pact terminal.

Enter atom . to open the directory in Atom.

Look through the code provided to better understand the contents of this smart contract.

It is slightly different than the hello world smart contract you had seen previously in the online editor. As you’ll see, it stores the value in a table and then returns that value using some of the Pact built-in functions you learned in previous tutorials.

That wraps up this tutorial. The goal of this tutorial was to get you up and running with Pact on the Atom SDK.

In this tutorial, you got started with Pact locally. You installed Homebrew, Atom, the language-pact package, and the Pact language. You also ran your first hello-world Pact program on your local computer.

Depending on your needs, you can now use both the online editor and the Atom editor to create Pact programs.