Skip to content
Urs Zeidler edited this page Jun 7, 2016 · 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.

usage

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

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

For more details see the solidity code generation section of the wiki.

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

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.

The generate solidity code action is available in the toolbar:

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

Clone this wiki locally