Usage

Sections in this article

Starting a Root Node

Once you’ve defined your node’s configuration, you can start your root node by running:

$ plasma --config <your-config-file>.yml start

The node will connect to your Ethereum client and begin creating blocks. By default, the JSON-RPC port will listen on port 8643.

Starting a Validator Node

Similarly, you can start a validator node as follows:

$ plasma --config <your-config-file>.yml validator --root-port <port> --root-addr <addr>

The node will immediately begin polling the root node for new blocks and automatically perform exits on your behalf if malfeasance is detected.

Inspecting Your Node

From another terminal on the same machine, you can query the state of your plasma node via the following commands:

  • plasma blocks --height <height>: Shows the transactions in the block at the specified height.
  • plasma balance: Shows the balance of the account specified by the user-address config variable.
  • plasma utxos --addr <addr>: Prints the UTXOs for the specified addr.

These commands read directly from plasma’s underlying LevelDB store.

Rest API

Your node also exposes a REST API which by default listens on port 6545. Below, see the following example requests and responses:

Note: Binary data is currently being string-encoded as base 64. We’re working on making it properly encode to hex.

Second note on numeric values: These are the base64 encoding of a byte string - i.e., []byte("1000") in Golang. We’re working on fixing this as well.

GET /v1/blockheight

Returns the highest block.

{ "height": "9" }

GET /v1/block/{number}

Returns a block and the transactions therein.

{
   "block":{
      "header":{
         "merkleRoot":"VSEQxBnlttKKzP/irWEltGaAiapSqj3mdGb0RvFwgq4=",
         "rlpMerkleRoot":"cKMA3F58rJbE8cqj3WRtqXs0ylT58/1BhuOX8QpVmCI=",
         "prevHash":"C72GjxDJyuUYso6hece6uPSKamrTZIEbT1MLWCI4/KE=",
         "number":"7"
      },
      "hash":"P+tvr+RBUoLsIkpKjANhGWiHanT51v+h1pATf/V6MhI="
   },
   "transactions":[
      {
         "input0":{
            "blockNum":"6",
            "outIdx":1
         },
         "sig0":"6IYtuY2fxpcNj3D1G4/MHF3fi9dqrb/QXxZ5nG5MXS8QKj+CXtg3DutkjoUjoa72oVIoMbbo6NPsl1ddeYa3DwA=",
         "input1":{

         },
         "output0":{
            "newOwner":"GJJHnbYDRdkaZ219R+3WrCY1bNo=",
            "amount":{
               "values":"MTAwMDAw"
            }
         },
         "output1":{
            "newOwner":"QG//yiptGZe571c9Z+/nS6eG3/E=",
            "amount":{
               "values":"OTk5OTk5ODk5ODEwMDAw"
            }
         },
         "fee":{
            "values":"MA=="
         },
         "BlockNum":"7",
         "RootSig":"/HEzC/Q4A4WIVRZO5UQPY408jXvvPLS45aTU1TdK1dkaOosx44HDo9KP1f2IMpKJg4R8pZv6DewJrXZ8E9GUfAE="
      }
   ]
}