Welcome to the Web3 Backend API project! This API provides user authentication, registration, and profile management functionalities using both Metamask and traditional credentials. It also supports changing user addresses and usernames.
Project created for fun and to learn myself a web3 development and testing. I wanted to share with world some of my code that can help others on their way.
Open project if someone wants to contribute or fork, go for it.
- User registration and login using Metamask.
- User registration and login using traditional credentials (username and password).
- A small User profile management, including changing addresses and usernames.
- Web3.js
- Express
- Postgres
- typeorm
- typescript
- Argon
- Mocha
- Joi
- Metamask
Provide instructions for setting up and running your project.
- Clone this repository:
git clone https://github.com/BitR13x/BlockChain-api.git - Navigate to the project directory:
cd BlockChain-api git clone https://github.com/OpenZeppelin/openzeppelin-contracts.git && mkdir -p openzeppelin && mv openzeppelin-contracts/contracts openzeppelin && rm -rf openzeppelin-contracts- Install dependencies:
npm install
3rd step is for clonning the openzeppelin library.
- Open
ormconfig.tsand configure database connection. - Open
config.tsand change according your needs.
// commands in package.json
{
"start": "nodemon --exec ts-node app.ts",
"start-node": "hardhat node",
"deploy": "hardhat run --network localhost scripts/deploy.ts",
"clean": "hardhat clean",
"test": "npm run test:server && npm run test:contracts",
"test:server": "mocha --require ts-node/register test/*.test.ts",
"test:contracts": "mocha --require ts-node/register/transpile-only contracts/test/*.test.ts"
}You can use npm or yarn to start tests or server.
Example: npm run start or npm run test:server.
List and briefly explain the API endpoints your backend provides.
/api- account routerPOST /api/loginPOST /api/registerPOST /api/delete/accountPOST /api/logout
/api/profile- profile routerPOST /api/profile/change-passwordPOST /api/profile/change-usernamePOST /api/profile/change-addressPOST /api/profile/change-email
/api/blockchain- blockchain routerPOST /api/blockchain/request-noncePOST /api/blockchain/authenticate- login or register using metamaskPOST /contract-info/:address- get own Data contract name and symbol.
/~testAPI- just test for status of server.