Build a Smart Contract

Morpheus Labs SEED is designed to provide you with a comprehensive cloud environment where you can easily develop and test a decentralized application. Rather than having to go through the hassle of using the command line to install multiple necessary complementary programs, the platform provides the tools you need for rapid development within the platform itself. Build, deploy on a test network and evaluate your work on our platform.

Here is an illustration of how you can build a simple DApp on Ethereum network with on our platform. We will use a decentralized lottery use case to illustrate how to develop and test an Ethereum smart contract using Morpheus Labs SEED.

Decentralized Lottery

In this sample smart contract which we will deploy and test on the platform later, we aim to build a self-repeating decentralized lottery application.

Mechanics:
Players will enter the lottery by sending Ether to the lottery, and the Manager of the lottery will trigger the random selection of the winner.

The winner will receive the ether from the prize pool into his account, and the contract will restart. When the contract restarts, the lottery can be played by a new set of players.

Variables:

NamePurpose
managerAddress/account that created the contract
playersArray of addresses that have entered the contract

Functions

NamePurpose
enterA player enters into the lottery
selectWinnerRandomly selects a winner, and sends the ether from the prize pool

1. Create a New Workspace

User guide numerals 4-1 and 5-1 for further reference.

a) Create a new blank repository

b) Go to dashboard - > create a New Workspace: lotteryWorkspace

c) Select to work with Ethereum blockchain:

d) Select stack -> ML - Truffle - Ganache

e) Select our repository

f) Select Blockchain endpoints

1254

After starting an Ethereum blockchain network under the "Blockchain Ops" page you can select the network at this interface.

g) Otherwise, we can leave it blank, and have the option to set it up afterward.

After the New Workspace configuration has been confirmed and submitted, the new workspace will be created although it must be activated before working on it.

Once the state indicator changes color to green, we can click on the title of the workspace to open the IDE and start building the Lottery Contract.

2. Build the lottery contract.

a) When the IDE opens, we can add a new file to the directory by clicking on the Create button in the Top-left corner of the window.
*Proceed to select File, and name it. For our demo case, we name it as lottery.sol

501

*.sol refers to a file written in solidity, which is the most used programming language to develop contracts for the Ethereum Virtual Machine (EVM), running on every node of the Ethereum network.

663

The sample contract

Our sample contract should look like this and it is now ready to be tested. More details on how it was built can be found in the appendix.