Skip to content

Romulus10/BlockchainSimulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

95 Commits

Repository files navigation

BlockchainSimulator

A blockchain simulator for SE 575

Open two terminal windows. In one, run the Simulator build, and in the other run the Frontend installation process, both of which are explained below. Once both are operational, navigate in a web browser to http://localhost:8100.

Simulator

Build

cd Simulator ./gradlew run 

(If both JRE and JDK are installed, gradle may use java from the JRE. Ensure JAVA_HOME is set to path of JDK.)

Frontend

Installation

  1. Install node.js if it is not already installed. https://nodejs.org/en/download/
  2. npm install -g ionic
  3. cd Frontend/ionic-app
  4. npm install
  5. ionic serve
  6. Website will be hosted on localhost:8100

Smart Contract Language

(NOTE: NOT INTEGRATED. TRANSACTION DATA IS LIMITED TO INTEGER VALUES FOR CURRENCY TRANSFER)

In order to carry out general computing and value-moving requirements, including the proof-of-stake algorithm, the blockchain simulator will include a simple smart contract system. The smart contracts will provide functions for simple, proof-of-concept programming structures, and will allow for transferring tokens between accounts.

Syntax

The smart contract language for this blockchain will be a fairly easily-assembled low-level language that will carry instructions for calculations in the following grammar:

.<label> <instr> <instr> <arg> <instr> <arg> <arg> <instr> <arg> <arg> <arg> 

Language Reference

CodeInstructionArgumentDescription
0nopNoneNo operation.
1mov'to' memory address, 'from' memory addressMove memory values.
2trntoken volume, 'to' account, 'from' accountTransfer tokens from one account to another.
3savmemory address, storage addressSave a value to permanent storage.
4lodmemory address, storage addressLoad a value from permanent storage.
5addaddress, valueAdd a value to a given memory location.
6subaddress, valueSubtract from a given memory location.
7muladdress, valueMultiply a given memory location by a value.
8jltx, y, labelJump to label if x is less than y.
9jgtx, y, labelJump to a label if x is greater than y.
10jeqx, y, labelJump to a label if x is equal to y.
11jmplabelJump unconditionally to a label.
12retxReturns the value in memory address x.
13actNoneCreates a new account on the chain.
14balacctRetrieve a balance given an account name.

Examples

Basic Math

add 0 1 add 0 1 ret 0 

Returns 2.

add 0 10 loop: add 1 1 jlt 1 0 loop ret 1 

Sets memory index 0 to 10, then adds 1 to memory index 1 repeatedly until it contains 10. Returns the value of memory index 1.

About

A blockchain simulator for SE 575

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5