This project involved building an embedded domain specific language in Haskell that could output Smart Contracts runnable on the Ethereum Virtual Machine.
In the FinancialExamples.hs file you will find seven example contracts that have been written using the DSL. You can begin writing new contracts here. You should define your contract variables and contract functions and then create an instance of the Contract data-type and assign it to some variable.
In order to ensure that the new contract you have written is outputted when the program is next run, you need to go to the Main.hs file and inside of the main function do block pass the variable representing the contract along with a string representing the output destination to the outputContract function.
To run the program you first need to install stack. Details can be found here: https://docs.haskellstack.org/en/stable/install_and_upgrade/
You then need to clone the repository and inside of the project folder run:
stack buildfollowed by:
stack exec HaskellContractsThe sample DSL contracts are currently being outputted to the ContractOutputs folder as Solidity files.
Unit tests have been written for the seven DSL example contracts implemented.
To run these tests you first need to install Node.js and npm, details can be found here: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm.
This will allow you to install the Solidity compiler (version 0.7.4) using:
npm install -g [email protected]You will then need to install testrpc using:
npm install -g ethereumjs-testrpcFollowed by installing truffle (version 5.1.67 exactly, using other versions may cause tests to fail) using:
npm install -g [email protected]To run the tests, you then need to open two seperate terminal windows and in one of those terminals run testrpc to simulate the actors in your blockchain using:
testrpcin the second terminal you should then navigate to the "EVM Testing/truffle" folder and run:
sudo truffle test