Authors: Sherif Abdekarim, Yotam Golan, Brooke Ryan
CS 295, Blockchain Systems
UC Irvine Winter 2022
Professor Faisal Nawab
This is the repository for the code associated with the paper A Blockchain Approach to Messaging Applications. It is a low-cost, minimalistic messaging application that runs on the Ethereum Virtual Machine. It was written in Solidity, which is a language designed for writing smart contracts for Ethereum-based applications.
This application was developed as a course project for CS 295 Blockchain Systems at UC Irvine under the guidance of Professor Faisal Nawab.
messaging_app.sol
contains the main code for the project. It contains the smart contracts for storage, the central contract, the sender, and receiver contracts.
messaging_app_optimizations.sol
contains code created for preliminary experiments regarding cost optimizations.
Note: The instructions provided here deploy the application to an Ethereum testing environment.
The following instructions delineate how to deploy all four of the Smart Contracts of the code provided in the paper. For some of the contracts, such as Sender and Receiver, there are multiple ways to instantiate a new user in the system. The outline below is just one of the ways.
- Open
messaging_app.sol
in the Ethereum Remix IDE. - Navigate to the compiler tab and compile
messaging_app.sol
.
- Navigate to the Deploy and Run Transactions Tab. Set the Environment to JavaScript VM (London or Berlin).
- Select the Storage smart contract from the Contract configuration. Press Deploy.
- Ensure that the Storage contract is now listed as a Deployed Contract.
-
Next, select centralContract from the Contract dropdown menu. Paste the memory address from the Storage smart contract into the
storage_address
parameter, then press transact. -
Next, we will deploy the Sender smart contract. Select Sender from the Contract dropdown menu. Paste the centralContract memory address into the
smart_contract_address
parameter, and then paste the encryption public key into thepublic_key_
parameter. (Ensure that the key is surrounded by quotation marks, since it is a string parameter.) Then press Transact. Ensure that the sender smart contract is listed under Deployed Contracts. -
Finally, we will deploy the Receiver smart contract. Select Receiver from the Contract dropdown menu. Paste the centralContract memory address into the
smart_contract_address
parameter, and then paste the encryption public key into thepublic_key_
parameter. (Ensure that the key is surrounded by quotation marks, since it is a string parameter.) Then press Transact. Ensure that the Receiver smart contract is listed under Deployed Contracts.
We now need to officially register the Sender and Receiver contracts to the central contract.
To do this, simply call create_user
from the respective Sender and Receiver contracts under the list of Deployed Contracts.
Now that the main contracts have been deployed, we can send and receive messages between the existing users in the system.
- First, under the deployed Sender contract, we will call the
get_public_key
function. Paste in the memory address from the Receiver contract. Press transact, and observe the response in the console.
- Then, on your own local machine, use the obtained public key to encrypt the message.
- Paste the receiver's memory address into the
receiver
parameter, and paste the encrypted message into themessage
parameter. Press transact.