Skip to content
UrsZeidler edited this page Feb 10, 2017 · 37 revisions

Welcome to the uml2solidity wiki!

A uml profile and a set of acceleo code generators to model smart contracts in uml and generate solidity code.

install

As the software is a plugin you will need the basic software which is the eclipse platform. It comes in a great number of flavors, like c++ dev environment or java. When you just interested in the modeling you could use the Papyrus Downloads

After getting the eclipse platform you need to install the solidity plugins from the updatesite: http://urszeidler.github.io/uml2solidity/uml2solidity-updatesite/.

Note that this is an p2 update site, so browsing it leads to an 404 unless you are a a p2 director.

select: Help->Install New Software

and paste the updatesite url in the site widget. You could checkout these eclipse help.

Or Drag to your running Eclipse workspace to install Uml to Solidity for installing with the marketplace client.

To work with mix you could simple open mix and the generated directory as project. Each time you regenerate the files there will be reloaded by mix.

Use Junit to produce fast and execute fast tests for the contracts.

usage

You could now simply use the prepared archetype which provides a maven project setup for eclipse and uml2solidity.

Create a model and apply the profile. Model your contracts and generate the code. Use the protected source parts to add the implementation. A basic usage is here. The profile is explained here. You could change some preferences. Lookup the papyrus documentation. Generate the files via launch configuration

Files to generate:

  • [package_name].sol the contracts of this model, currently one file is written for each package containing contracts or interfaces
  • [package_name].md a simple description of the model
  • [package_name].html a simple generated html interface
  • [package_name]Web3.js a simple api description
  • [preference js controller directory/contract_name].js all the js scripts to control the html gui
  • .mix the configuration file for mix, refers all the generated files
  • [class_name]Test.java a junit test case for each contract
  • [package.name]TestSuite a junit test suite containing all tests generated for the packages, so for all contracts contains in this package

For more details see the solidity code generation, the generated js code and the java code section of the wiki. The generation process is controlled by a launch configuration.

current limits

Some current limits in the modeling and the code generation.

  • sub package are not generated in it's own folder

feel free to open new issues.

create a model

You could now simply use the prepared archetype which provides a maven project setup for eclipse and uml2solidity.

in fast: You can load a template, there is a template with the profile applied and an import of the solidity type model. Or: Select new model, select and apply the solidity profile and also add the solidity types.

step by step:

create a papyrus project;

name the project:

select the uml model as diagram language:

name the model and create a class diagramm:

apply the solidity profile to the model:

finish the wizard:

import the solidity types by select the model in the modelexplorer:

generate code

After modeling your contracts, applying the stereotypes, you can generate the solidity code. The code will be generated in a sub directory called mix. When using mix you could open this directory as mix project and the generated files are loaded into mix. Now you could start to flesh out the contracts by adding the behavior code. Place your code in the protected parts. So it will stay even if you generate the code again.

Generate java code like interfaces and junit tests.

The generate solidity code process is a run configuration:

See the launch configuration

If you already have the mix program opened the files will be reloaded. See the generated code section in the wiki or the js code.