Insurechain is a DAPP solution that comprises a technological ecosystem designed to build the next generation of Web3 insurance.
The web application is deployed here.
You may find the project slides here.
- Frontend: Next.js
- Backend: Nest.js
- Database: Prisma and PostgreSQL
- Blockchain: Ethereum
- Tokens: Ethereum ERC20
- Smart Contracts: Solidity
To initialize the database locally, first we have to run the Docker container with the database:
npm run db:up:devTo seed the database:
npm run db:seed:devIn order to perform a migration, let's suppose the schema is already edited. Take into account that on init the database the seed is already performed automatically. To migrate we may run:
prisma migrate dev --name migration_titleEven if we have to init for the first time the database or we have perform some modifications and we want to run the migrations we have to run the following command:
npm run db:migrate:devTo reset our database with the seed:
rm -rf prisma/migrations && npm run db:migrate:devWe can use the Prisma Studio to visualize the data of our database:
npm run db:studio:devIn order to use a production database you just have to define the .env.production file
setting the DATABASE_URL variable you may run the same commands with the prod config:
npm run db:up:dev
npm run db:migrate:prod
npm run db:studio:prodIf we want to update the production database schema and tables with the local tables we have to run:
prisma db pushBy contrast, if we want to pull the production schema and tables to our local we have to run:
prisma db pullTo init the local blockchain network and automatically deploy the smart contracts we just have to run:
npm run hh:startThis will serve the hardhat network at http://127.0.0.1:8545/ and when network pings it will deploy the contracts to such network using the account generated by Hardhat.
To init the local blockchain we have to run:
npm run hh:networkThis will run a node server on port 8545 to simulate the blockchain. It will provide 20 accounts with 10000 ETH each one which you can import to your wallet or DAPP. If you want to import them to your Metamask wallet you can follow this tutorial.
To deploy contracts we must use the deploy script located at "scripts/deploy.ts". We must modify such script to add our contracts. Take into account that local network server must be running. Then, we can deploy our contracts running:
npm run hh:deployTo write tests we should locate them at "test/". Then, we can run them with:
npm run hh:testTo compile contracts we must ensure they are located at "contracts/". Then, we can compile them running:
npm run hh:compile