Permalink
Switch branches/tags
better-logging-around-trees better-storage-error-message better-without-snark bignum-mul bugfix-incorrect-strength bugfix bundler calculate-strength change-jbuild-warnings coda-randomized-test coda_worker_mls debugging-merkle-mask-coda-base dual-variables edwards-param-gen election-example es92-readme-patch-1 es92-readme-patch fast-pedersen-hash feature/any-base-ledger feature/any-mask-ledger feature/ban_list_rocks_db feature/bg-snark-in-libsnark feature/bootstrap-controller-integration feature/bootstrap-controller feature/c++pedersen feature/consensus-documentation feature/faster-pedersen feature/field-extensions feature/leveldb-for-key-value-store feature/mac-build feature/merkle-mask-in-coda-base-ledger feature/metrics feature/protocol-state-summary feature/stake-pool feature/track-delegates feature/transition-frontier-coda-interface feature/transition-handler-processor-unit-tests feature/user-submitted feature/verify-txn-in-diff-new fix-1001 fix-dying-prover fix/clearer-tx-snark-output fix/coda-base-signature-refactor fix/curve-unsafe-add fix/dockerbuilds fix/dont-hide-secrets-for-now fix/fail-rpc-connection fix/first-assertion-passed fix/implement-remove-accounts fix/improve-bitstring-compare fix/no-failwith fix/other-mask-delegations fix/remove-constraint-system-from-proving-key fix/savekeys fix/snark-test-profile fix/use-ledger-modules-for-mask-and-database fix/with-valid-signature-no-bin-io fix/worker_logging_simple frontier-announces-best-tips functor-keys further-snark-tests groth-maller groth-verifier-in-libsnark groth_verifier hook-in-snark-pool integrate-transaction-snark interval-union-fix ledger-diagram logproc-json make-bitstring-everywhere master merge-in-master minibit-miner-impl mnt-cycle-search mnt_newgroth name_your_spawn new-master pipe-forking pos-snark prepare-for-tx-snark-integration random-sorted-work readme-disclaimer receipt-blog-post receipt-chain revert-1123-feature/delegate-in-account rfc/fix-bad-numbering rfc/ipfs-net rfc/snark-worker-policy rfc/transition_frontier_bootstrap rfc/update-merkle-mask rip-out-old-pipe-master signed-payload simex simulator-static snark-pool-rebroadcast-if-relevant snark-worker-coordinator snarkette snarky-cps snarky-tutorial style-guidelines-test-stubbing tease-ledger-builder testnet-client testnet tfc-staging tmp-defunctorize tmp/bigger-ledger-debug tmp/staging-for-corey toy-calculator transaction-bundler transaction-snark tx-snark-profiling update-libsnark use-db-ledger website-new-jobs
Nothing to show
Find file Copy path
164 lines (100 sloc) 6.41 KB

Tutorial: Coda Quickstart

Introduction

Hello! We'll walk you through a short demo to get a local testnet running using Coda.

Specifically, you'll download a docker image, run it, then play around with the command line interface to create a wallet and send/receive payments.

Helpful links

Prerequisites

While you don't need to be a seasoned OCaml hacker to follow this guide, you should have a background or familiarity with common development patterns. If you know how to use the terminal, install a docker image, read developer documentation, and have access to a Linux-based operating system, you should be able to follow this guide.

Demo

At a high level, you'll follow these steps:

  1. Verify your system
  2. Run the docker image
  3. Interact with the network

We'll walk through them one by one.

Verify your operating system

Software: You need to be running a Debian 9 or Ubuntu 18 distribution, either natively or in a VM. These are the only operating systems we have tested against. If you don't have this running locally, there are instructions in the appendix to set up a Google Compute instance.

Hardware: We'll be running three nodes on your machine, including a node that is performing intensive zk-SNARK proving work. Therefore, we recommend the following system requirements: 12GB ram (you may be able to get away with less), 4 cores.

Download the docker image

First, you'll need to install Docker 18.06 on your machine. You can do so by following the instructions here: Mac, Ubuntu, Windows.

WARNING: Most of these commands won't work as shown unless you manage Docker as a non-root user. You can either follow the linked instructions OR run the following commands as root.

Now, create a directory where you can work, and run the docker image:

$ docker run -d --name coda codaprotocol/coda:demo

Now, connect to the docker process with the following command:

$ docker exec -it coda /bin/bash

Interact with the network

At a high level, here's what just happened: you started three Coda nodes, all of which are running locally on your machine over your localhost network.

There are a few ways you can interact with this network right away:

We'll show some code snippets for each of these actions below.

Check the network status

We use this general command to check the network's status (from the view of a particular node):

$ coda client status

Since you're running three nodes, the command above will fail. You have to specify the port that your nodes are running on. The following commands should work -- and give a consistent view of the network:

$ coda client status -daemon-port 8301
$ coda client status -daemon-port 8401
$ coda client status -daemon-port 8501

If you just want to have a running status page of the entire network, try running this:

$ watch coda client status -daemon-port 8301

Create a wallet

A wallet in Coda is just a public/private key pair. The public key corresponds to your publicly available address, and the private key is like a password, required to authorize sending funds from that address.

First, create a directory for your wallet:

$ mkdir wallet

The following command will generate a public/private keypair and prompt you for a password to encrypt the private key file:

$ coda client generate-keypair -privkey-path ./wallet/key

That creates an encrypted private key file at ./wallet/key and a corresponding public key file at ./wallet/key.pub. To check your public key, you can run

$ cat ./wallet/key.pub

Send payments

For ease of setup and experimentation, we've already given you a well-funded account, which you can use to send payments to new accounts. Here's how you can send a payment from this account:

$ coda client send-txn -amount <AMOUNT> -privkey-path ./funded-wallet/key -receiver <RECEIVER_ADDRESS>

Replacing the <AMOUNT> argument with an integer value and the <RECEIVER_ADDRESS> with the public key of the account you're sending money to. It will prompt you for the private key password but it is blank.

Check account balances

Naturally, you might be interested in seeing how and when the network processes your payments. You can do that by either inquiring for a specific address or all account balances. Here are the commands to do so:

Checking account balance

$ coda client get-balance -address <PUBLIC_KEY>

Checking everyone's account balances

$ coda client get-public-keys -with-balances

Add additional nodes to the network

To spin up additional nodes, you'll need to point them to existing, running nodes. You can see how we spin up the nodes used in your network by reading through ./scripts/cluster.sh, and if you want to spin up new nodes, you can follow the patterns there.

Then, you can check whether this node is up and running with the following status command:

$ coda client status -daemon-port <PORT>

Appendix

This will show you how to get up and running with an appropriate Linux distribution on Google Cloud. We'll cover a few steps: 1) getting the instance set up, 2) interacting with the machine on the command line.

Setting up the instance

To get the instance set up, follow these instructions, with the following changes:

  • Choose Ubuntu 18.04 LTS as the OS.
  • Instead of 1 vCPU, choose to have 4 vCPUs
  • If you're on the west coast, instead of choosing us-east1 choose a west coast region
  • Change the amount of ram to 12GB

Interacting with the CLI

To interact with the CLI, go to the compute engine -> VM instances page.

Then, select the VM, start the VM, and click the SSH button to open up a terminal window.