This project implements a staking contract in Solidity that allows users to stake ERC20 tokens and earn rewards over time. The backend service uses Node.js with Express to fetch staking data from the Ethereum blockchain via Alchemy.
- Stake tokens and earn rewards
- Withdraw staked tokens
- Claim accumulated rewards
- Admin functionality to set reward rates and deposit rewards
- Fetch staking data by user address using Alchemy’s JSON-RPC API
- Expose API endpoints for the frontend to retrieve staking data
- Node.js
- Alchemy API Key
- Ethereum Wallet with Sepolia test tokens (or applicable network tokens)
- Deploy Contract
- The contract uses OpenZeppelin libraries for access control and security.
- Set the reward rate and staking/reward tokens upon deployment.
-
Clone the repo:
git clone <repo-url> cd <project-directory>
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory and add the following environment variables:ALCHEMY_API_KEY=<your-alchemy-api> STAKING_CONTRACT_ADDRESS=<your-staking-contract-address>
-
Start the backend service:
npm run start