Basic Node.js Express backend API, with MongoDB database and Ethereum blockchain.
Disclaimer: this is not a DApp per se. Actually it's more of a 'CApp' (Centralized App), as the intelligence and the users' private keys are stored in the server. The Ethereum Blockchain is used to validate and store transactions, but there is no smart contract capabilities.
-
Prerequisites: You need to have Git, Node/npm, MongoDB and Ganache installed on your computer
-
Clone the repo
-
Install npm dependencies (
package.json
)
npm install
- Run MongoDB in the background (in another terminal)
sudo service mongod start
-
Run Ganache (GUI / CLI)
-
Run the server. It will be available at
http://localhost:3000
npm run start
- Node.js + Express + Mongoose + Web3.js
- MongoDB database
- Blockchain: Ganache (Ethereum Local Testnet)
- Authentication using
JWT
(pass the token in the headerx-access-token
) - Tests with Mocha & Chai
- Linting with ESLint (Airbnb Style Guide + some custom rules)
Login
POST /api/v1/auth/login
Users
GET /api/v1/users
POST /api/v1/users
GET /api/v1/users/:user_id
PUT /api/v1/users/:user_id
DELETE /api/v1/users/:user_id
Transactions
// GET /api/v1/transactions
GET /api/v1/transactions/:transaction_id
User Transactions
GET /api/v1/users/:user_id/transactions
POST /api/v1/users/:user_id/transactions
Address Transactions
GET /api/v1/addresses/:address_id/transactions
Block Transactions
GET /api/v1/blocks/:block_number_or_hash
Tip: you can interact with the API with a tool like Postman
node db/seed.js
npm run test
npm run lint
node scripts/ethereum_scriptsjs <command>
// command: accounts, balance, unlock, send, transaction, account_transactions, block
// (+ additional parameters needed in some cases)
- Encrypt User.ethereum_account_private_key in database
- Authorization layer: can only update your data, can only view your transactions, etc
- Integration Tests with Ethereum/Ganache
- Unit Tests
- Mockgoose in memory database for tests
- REPL to interact with the database using the models