Skip to content

smart contract implementation according to the Plasma MVP spec.

License

Notifications You must be signed in to change notification settings

FourthState/plasma-mvp-rootchain

Repository files navigation

PLASMA MVP

travis build license Coverage Status

Implementation of Minimum Viable Plasma

Note: The develop branch contains the current development for v2 of the rootchain contract.

Project Status

There is very little development occuring for this project. We will continue to maintain this repository by thoroughly reviewing any open source contributions. We will provide support and guidance for anyone looking to continue development.

Overview

Plasma is a layer 2 scaling solution which conducts transaction processing off chain and allows for only merkle roots of each block to be reported to a root chain. This allows for users to benefit from off chain scaling while still relying on decentralized security.

The root contract of a Plasma child chain represents an intermediary who can resolve any disputes. The root contract is responsible for maintaining a mapping from block number to merkle root, processing deposits, and processing withdrawals.

Root Contract Details

A transaction is encoded in the following form:

RLP_ENCODE([
  [Blknum1, TxIndex1, Oindex1, DepositNonce1, Input1ConfirmSig,

   Blknum2, TxIndex2, Oindex2, DepositNonce2, Input2ConfirmSig,

   NewOwner, Denom1, NewOwner, Denom2, Fee],

  [Signature1, Signature2]
])

The signatures are over the hash of the transaction list (first list) signed by the owner of each respective utxo input.

Documentation

See our documentation for a more detailed description of the smart contract functions.

Testing

  1. git clone https://github.com/fourthstate/plasma-mvp-rootchain
  2. cd plasma-mvp-rootchain
  3. npm install
  4. npm install -g truffle ganache-cli // if not installed already
  5. ganache-cli // run as a background process
  6. npm test

Running

The first migration file 1_initial_migration deploys the PriorityQueue library and links it to the RootChain contract, while the second one 2_deploy_rootchain finally makes the deployment. Ethereum requires libraries to already be deployed prior to be used by other contracts.

If you encounter problems, make sure your local test rpc (e.g. ganache) has the same network id as the contract's json from the build folder.

Contributing

See our contribution guidelines. Join our Discord Server.