Смарт контракты

Published 14 January 2019

Creating a simple smart contract

Smart contract on the Credits platform

Smart contract on the Credits platform

The Credits platform uses the Desktop Wallet app development environment to develop smart contracts. Smart contract is developed using Java language. This allows you to design and test on absolutely any platform without having to install a special development environment.

Simple smart contract

Simple smart contract

A prerequisite for implementing a smart contract class is its inheritance from the SmartContract class.

public class Contract extends SmartContract {

   public Contract() {

   }

   String hello() {

      return "Hello, I am a simple smart contract";

   }

}

in this simple smart contract, there is only a class builder and a class method that returns a string.

Create and verify a smart contract with the Desktop Credits wallet

Create and verify a smart contract with the Desktop Credits wallet

You need to click on the following menu item in the Desktop Wallet:

Next, the smart contract entry screen opens:

The right side of the window shows the builder and method(s) of the smart contract.

The sequence is as follows: enter the text of the smart contract, then click "Build", if there are no errors, the lower part of the smart contract source code window will be empty, then click "Deploy". A message that indicates that the smart contract is published successfully looks like this:

Note: full database synchronization is required for successful publication

After clicking the "Build" button, the window will look as follows in case of an error in the code of the smart contract:

How to find and run the published smart contract methods

How to find and run the published smart contract methods

To find the published smart contract you need to go to the "Execute smart" tab

The page with published smart contracts looks like this:

methods of the selected smart contract are displayed on the same page.

To view the source code of a smart contract, go to the "See the Code" tab

Votes 0, average rating 0

Contents