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.
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.
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.
|manager||Address/account that created the contract|
|players||Array of addresses that have entered the contract|
|enter||A player enters into the lottery|
|selectWinner||Randomly 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
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
*.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.
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.
Updated almost 3 years ago