Skip to content

BasicUsage

UrsZeidler edited this page Nov 12, 2016 · 15 revisions

Basic usage

A brief overview how to develop smart contracts with eclipse, uml and mix together.

(Here is work in progress.)

prerequisites

You need eclipse and the papyrus software the best starting points are the modeling.

See install for more details.

workspace and project

In eclipse the files are stored in the workspace and organized as projects. When you use js as frontend code it is good to convert the project to a java script project. If you want to use the project setup described in junit testing with java for junit testing follow this instruction, you can always add the java script nature later on.

preferences

The preferences are used for meaningful defaults. There are used to populate a launch configuration when it gets created. The properties have a global and a project scope. See the preferences section in the wiki.

Add the solidity compiler in the compiler preferences if you like. compiler-preferences

create a model

Create a simple uml model, add the registered profile.

create a papyrus project name the project
select the uml model as diagram language name the model and create a class diagramm
create a model from the template

Or :

apply the solidity profile to the model finish the wizard

create a model from template

To create a properly configured project use the template.

create a model from the template

adding stereotypes

Adding model elements is defined in http://wiki.eclipse.org/Papyrus_User_Guide and ...

To add a stereotype select the element and ...

changing stereotype properties

The stereotype properties are available at the profile tab of the properties view, there all applied stereotypes are listed together with their properties.

working with the model

The property view is your best friend also the also the model explorer comes handy, both are displayed in the papyus perspective.

adding elements

The papyrus editor is straight forward you add new elements by selecting it in the tool section.

adding contracts

To add a contract you need to add a class and apply the Contract Stereotype.

adding fields

Add Fields and assign a type.

adding functions

Contract functions are modeled by operations with the stereotype GFunction applied.

adding events

Events are modeled also a operations, but it has the Event stereotype applied.

work with modifiers

Modifiers are modeled as constrains, when the modifier has input parameters you need to apply the modifier stereotype, to link the modifier to a function you can add a modifier datatype to the function stereotype, this is a bit crude, and linking the modifier to the function and set the parameters.

It is also possible to link the operation to the constrain, when the modifier has no parameters.

There is a constrain 'payable' in the Types model, so you don't need to create it for your self.

work with mappings

generate the code

customize the code

customize solidity code

customize js code

js page code
js test code

Clone this wiki locally