A decentralized expense management application built on the Ethereum blockchain using Solidity and React.
- Introduction
- Features
- Technologies Used
- Setup and Installation
- Usage
- Smart Contract Details
- Contributing
- License
Dxpense is a decentralized application (dApp) that allows users to manage their expenses securely on the blockchain. It leverages Ethereum smart contracts to ensure transparency and immutability.
- Add and manage expense records.
- Fetch and display expense data from the blockchain.
- Secure transactions using MetaMask.
- Frontend: React, ethers.js
- Blockchain: Solidity, Ethereum
- Tools: Hardhat, MetaMask
-
Clone the repository:
git clone https://github.com/software-community/DXpense.git cd Dxpense
-
Switch to the master branch
git checkout master
-
Install dependencies:
npm install
-
Start a local node:
npx hardhat node
-
Deploy Smart Contract: In a new terminal, enter:
npx hardhat ignition deploy ./ignition/modules/Dxpense.js --network localhost --reset
-
Set up environment variables by creating a .env in the client directory and entering the following:
REACT_APP_CONTRACT_ADDRESS=<Your_Contract_Address>
-
Install client side dependencies
cd client npm install
-
Run the app:
npm start
-
The app will prompt you to install metamask, which is a wallet for ethereum based tokens. Install the browser extension for metamask and create an account.
-
Inside metamask, click the networks dropdown->Add Custom Network and enter the following details:
- Network Name: GoChain Testnet
- Default RPC Url: http://127.0.0.1:8545/
- Chain ID: 31337
- Currency Symbol: GO
- Once you've saved the network, switch to the GoChain Testnet network you just created.
- Now click the Account dropdown -> Import Account and enter the private key of one of the accounts that were created when you ran the "npx hardhat node" command. You'll find these accounts listed in the first terminal. After a minute or so you should see some money in this account. Now you're all set to interact with the app.
- Open the application in your browser.
- Connect your MetaMask wallet.
- Interact with the dApp. Right now you can only add and view names stored in a list stored on the blockchain. Enter your name and click the add name button. You will see your name appended at the end of the list of names once the transaction goes through and you refresh the page.
- Contract Name:
Dxpense
- Functions:
addName(string name)
: Adds a new name to the contract.getNames()
: Fetches all stored names.
Contributions are welcome! If you have suggestions or find any issues, feel free to open an issue or submit a pull request.
Navigate to the contracts directory and open Dxpense.sol to make changes to the smart contract. The following steps need to be followed in order for the changes to be reflected on the frontend:
- Compile the smart contract:
npx hardhat compile
- Deploy the smart contract:
npx hardhat ignition deploy ./ignition/modules/Dxpense.js --network localhost --reset
- Add the deployment address to the .env file in the src folder of the client directory
- Update the smart contract ABI file. Navigate to the artifacts/contracts/Dxpense.sol/Dxpense.json file and copy the abi array. Paste it into the Lock.json file in the src folder of the client directory.
- Finally, restart the react server using npm start.
This project is licensed under the MIT License. See the LICENSE file for more details.