This project provides an API to store and retrieve user-specific messages on the blockchain. All blockchain operations are performed through a single application wallet, but the API allows associating each transaction with a specific user by storing userId
along with the message data.
- Store user-specific messages on the blockchain
- Retrieve all messages stored on the blockchain
- Fetch messages for a specific user by their
userId
Make sure you have the following installed before running the project:
- Node.js
- npm
- Web3.js
- Active Metamask account with testnet blockchain (this project uses fantomTestnet)
-
Clone the repository:
git clone https://github.com/OsmosysSoftware/blockchain-backend-transaction cd blockchain-backend-transaction
-
Install the dependencies:
npm install
-
Configure the
.env
file with your Ethereum account's private key and contract details:PRIVATE_KEY=<your-wallet-private-key> PROVIDER_URL=<your-testnet-blockchain-url> CONTRACT_ADDRESS=<your-deployed-contract-address>
-
Deploy the smart contract :
You can either deploy the contract manually using
truffle
orhardhat
or include a script in the project for automated deployment.
-
Start the server:
node server.js
The server will run on
http://localhost:3000
. -
Use the available API endpoints to store and retrieve messages. Check the API Document