Skip to content

rwth-acis/las2peer-registry-contracts

Repository files navigation

las2peer Service Registry Smart Contracts

This repo contains Solidity smart contracts for an Ethereum-based service registry for las2peer.

Development Status

The contracts are very much a work in progress and not ready for production use. However, you can try out the development environment and play around with the contracts in an IDE like Remix or on the command line.

Installation & Dependencies

This project is distributed as an npm package and uses the truffle Ethereum development framework as a build and deployment tool.

Installation

  • If you haven’t already, install Node.js with npm.
  • Clone this repo and run npm install in the root folder. This will install truffle and other dependencies.

Ethereum client setup

You are free to use any blockchain and JSON-RPC-enabled Ethereum client (adjust truffle.js accordingly), but the simplest way is to use ganache-cli, which is included as a developer dependency. It should suffice to run:

npm run start-ganache

And later:

npm run stop-ganache

That’s it — the default configuration is fine. This sets up a local blockchain for development purposes and serves its API on port 8545. Don’t worry, with these settings, mining blocks does not fry your CPU. By default, the blockchain data is not persisted, i.e., restarting ganache will give you a blank slate.

If you actually want to see what’s going on, run ./node_modules/.bin/ganache-cli directly, or even install and run the Ganache GUI for a pretty visual interface.

Optional: set up convenient shortcuts for the truffle and ganache-cli executables.

Truffle, ganache-cli, and other developer dependencies’ binaries can be found in ./node_modules/.bin/. If you find this inconvenient and would prefer to access them simply by their name, you have several options.

  1. Install them globally with npm, e.g., npm install --global truffle. This makes sense if you want to use a tool in other projects too.
  2. Set up an alias for each tool you want to use, e.g., alias truffle="$(realpath ./node_modules/.bin/truffle)".
  3. Modify your PATH, e.g., export PATH="$(realpath ./node_modules/.bin):PATH", if you want to make all tools from the .bin directory available.

To make the alias or PATH persistent, put the commands with the absolute path in your shell configuration script.

Deploying contracts and running tests

The compilation of the contracts, deployment of the bytecode contracts to the blockchain, and running tests is all handled by truffle.

Compilation and deployment can be run manually via truffle’s compile and migrate commands, but simply running the tests will also trigger these steps if necessary. Thus, simply try:

npm run test

This requires a running Ethereum client as described above.