Skip to content

gerardcastell/insurechain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

210 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Insurechain

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.

Stacks

  • Frontend: Next.js
  • Backend: Nest.js
  • Database: Prisma and PostgreSQL
  • Blockchain: Ethereum
  • Tokens: Ethereum ERC20
  • Smart Contracts: Solidity

Database Commands

Local Database

To initialize the database locally, first we have to run the Docker container with the database:

npm run db:up:dev

To seed the database:

npm run db:seed:dev

In 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_title

Even 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:dev

To reset our database with the seed:

rm -rf prisma/migrations && npm run db:migrate:dev

We can use the Prisma Studio to visualize the data of our database:

npm run db:studio:dev

Production Database

In 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:prod

If we want to update the production database schema and tables with the local tables we have to run:

prisma db push

By contrast, if we want to pull the production schema and tables to our local we have to run:

prisma db pull

Blockchain Commands

Local Blockchain with Hardhat

To init the local blockchain network and automatically deploy the smart contracts we just have to run:

npm run hh:start

This 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:network

This 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:deploy

To write tests we should locate them at "test/". Then, we can run them with:

npm run hh:test

To compile contracts we must ensure they are located at "contracts/". Then, we can compile them running:

npm run hh:compile

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors