## 4 Implementation
### CEA-DApp  
This study developed a CEA-DApp as a front-end system, to make it more convenient for the user to interact with the IPFS private network and CEA Network. It was built on the Truffle Suite framework, using ReactJS programming. This DApp has a smart contract named CEAContract.sol, to store the hash of a file. The CEAContract.sol contains a state variable storedData typed string to model the hash of a file from IPFS. It also contains set and get functions. The set function receives an input value and stores it in storedData, while the get function displays the storedData value. Before deploying a smart contract in CEA Network, generated accounts from CEA Network are import into Metamask and unlock them. Figure 9 shows CEAContract.sol deployment on the CEA Network. It is stored as a transaction on the distributed ledger and identified by its transaction hash. After it is deployed, the smart contract will get a contract address as its identity and an application binary interface (ABI) as a description of the deployed contract and its function [16]. As seen in Table 2, the contract address and ABI are used in a web3.js library, to allow the interaction between the ReactJS program and the smart contract. \begin{table}
\begin{tabular}{c c} \hline \hline
**Nodes** & **Screenshot** \\ \hline \multirow{7}{*}{Boot Node} & con3@con3-optPlex-3050:-/.ipfs5 IPFS\_LOGGINGccrtittal tpfs daemon \\  & Initialize daemon... \\  & go-ipfs version: 0.4.18- \\  & Repo version: 7 \\  & System version: and64/linux \\  & Golang version: 901.11.1 \\  & Successfully raised file descrpttor lintt to 2048. \\  & Swarm ts limited to private network of peers with the swarm key \\  & Swarm keyfingerprint: afcc0321 ceefb1 bc0a8c13b187 bc369b \\ \hline \multirow{7}{*}{Client\_1 Node} & \multirow{7}{*}{Client\_1 Node} & \multirow{7}{*}{Client\_1 Node} \\  & & \\  & & \\  & & \\  & & \\  & & \\  & & \\  & & \\  & & \\ \hline \multirow{7}{*}{Client\_2 Node} & \multirow{7}{*}{Client\_2 Node} & \multirow{7}{*}{Client\_2 Node} \\  & & \\  & & \\  & & \\  & & \\  & & \\  & & \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Starting the local nodes in the IPFS private network. 2_deploy_contracts.js  
Replacto 'CEAContract'  
> transaction hash: 0x43b35 feb74e3307 cd3e3 dc4e08 efd6f618032c6 aa3d082b6 bf940e963b91f4e65  
> Blocks: 1 Seconds: 4  
> contract address: 0x326147443210e58 AD04583897307 Cc26 cd75  
> account: 0x15928827 ffe16d81182D914 ab8 Df75416B24681  
> balance: 99999.97554388  
> gas used: 217008  
> gas perce: 20 guef, > value sent: 0 ETH  
> total cost: 0.00542016 ETH  
> Savving migration to chatn. > Savving artifacts  
The CEA DApp interacts with CEA Network, which is run on http://localhost:8543, and accesses the IPFS private network API using an ipfs-http-client library, which runs on IPFS daemon at port 5001. Therefore, CEA DApp can upload and download files on IPFS. The front-end consists of the upload and download page. A class-named app is used on the upload page. It contains a state as an object that holds information, like ipfsHash, buffer, and transactionHash. As seen in Table 3, the system calls function onSubmit to store the file on the IPFS private network when uploading the file. The file is converted into a buffer (an array with data) before it is uploaded into the IPFS private network. The IPFS private network returns a hash of the file. Then it triggers the Metamask to confirm the transaction. After the transaction is successfully confirmed, the CEA Network start the mining process to put the transaction in a block. Then, the CEA Network will return a Transaction ID. Before doing this transaction, the account in the CEA Network must be unlocked. \begin{table}
\begin{tabular}{l l} \hline \hline
1: & import _web3_ \\
2: & initiate smart contract address = _address_; \\
3: & initiate smart contract abi code = _[abil]_; \\
4: & export _address_ and _[abil]_ into _web3_ provider \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Algorithm for Integrating Smart Contracts with ReactJS.