Running Michelson

Running on the alphanet

Here's how to run a contract on the alphanet. The container: prefix tells the docker to copy the file into the container before running the client. It does change the path, so just know that it's still your file that's causing the errors. You'll need to obtain and start the alphanet before doing any of these things. Instructions can be found on the Tezos GitHub.

Typechecking contract on the alphanet

  ./alphanet.sh client typecheck program container:/tmp/program.tz

Run a contract on an input

Replace [STORAGE] with a value of the storage type and [INPUT] with a value of the parameter type.

  ./alphanet.sh client run program container:/tmp/program.tz on storage [STORAGE] and input [INPUT]

Typecheck a piece of data

Same as above. Just replace [DATA_LITERAL] and [TYPE] with the piece of data and expected type.

  ./alphanet.sh client typecheck data [DATA_LITERAL] against type [TYPE]

Originate a contract on the alphanet

This will push the contract live to the blockchain.

By default, the alphanet has the identity my_identity installed. It also has the account my_account available as a source of funds (with a decent starting balance).

  ./alphanet.sh client originate contract [CONTRACT_NAME] for [IDENTITY] transferring [STARTING_BALANCE] from [SOURCE_OF_FUNDS] running container:[PATH_TO_PROGRAM]

Here's a full example:

  ./alphanet.sh client originate contract program for my_identity transferring 100 from my_account running container:/tmp/program.tz

Running without the alphanet

Before you're able to use any of these commands, you'll need to build the Tezos node and client from the Git repository. Basic build instructions can be found here. If you're building on different platforms, you may experience problems with the libsodium dependency. Fixes are described in various locations, such as this one.

Before actually running anything, you'll need to start a Tezos node and activate the alpha protocol. There are some scripts in the repository designed to make this easier. The official documentation is here, but I'll go through the steps anyway.

Starting a Node and initializing the client

I'm assuming that you're in the top directory of the Tezos repository for this sequence of commands.

First, start a sandboxed node. A sandboxed node cannot contact the actual network and is meant to be a testing area. Sandboxed nodes can still contact addresses on your local network, but they won't by defualt.

You can do this in another terminal, or by backgrounding the following process. I personally usually work in a single terminal, so I'll be backgrounding things.

scripts/launch-sandboxed-node.sh 1 --connections 0 &

Next, initialize a client that can contact the node. This will inject a few different aliases into the current shell.

eval `scripts/init-sandboxed-client.sh 1`

Finally, activate the alpha protocol:

tezos-activate-alpha

Run a contract on an input

Replace [STORAGE] with a value of the storage type and [INPUT] with a value of the parameter type.

tezos-client run program /tmp/program.tz on storage [STORAGE] and input [INPUT]

Typecheck a piece of data

Same as above. Just replace [DATA_LITERAL] and [TYPE] with the piece of data and expected type.

tezos-client typecheck data [DATA_LITERAL] against type [TYPE]

Originate a contract

This will push the contract live to the blockchain.

With the sandbox, it's easier to use the bootstrap identities.

tezos-client originate contract [CONTRACT_NAME] for [IDENTITY] transferring [STARTING_BALANCE] from [SOURCE_OF_FUNDS] running [PATH_TO_PROGRAM]

Here's a full example:

tezos-client originate contract program for bootstrap1 transferring 100 from bootstrap1 running /tmp/program.tz