The ERC20-Bridge Backend is the backend application for the ERC20-Bridge smart contracts. It facilitates the communication with the smart contracts, handles event listening, and interacts with a MySQL database using Prisma to store relevant data.
The ERC20-Bridge Backend serves as the communication hub for the ERC20-Bridge smart contracts. It handles event listening, processes events, and stores relevant data in a MySQL database using Prisma.
Before setting up the ERC20-Bridge Backend, ensure you have the following prerequisites:
- Node.js
- MySQL Database
- Prisma CLI
- Ethereum RPC Endpoints
-
Clone the repository:
git clone https://github.com/DanielDimitrov5/ERC-20-Bridge-Signatures.git
-
Install dependencies:
npm install
-
Set up the database:
npx prisma migrate dev
Configure the ERC20-Bridge Backend by creating a .env file with the following variables:
DATABASE_URL=mysql://username:password@localhost:3306/database
RPC_URL_MAINNET=https://ethereum-rpc-endpoint.com
RPC_URL_SEPOLIA=https://ethereum-rpc-endpoint.com
RPC_URL_GOERLI=https://ethereum-rpc-endpoint.com
PRIVATE_KEY=your_ethereum_private_key
RPC endpoints for the chains you want to listen to are required. The private key is used to sign transactions and must be the same for all chains.
The project is structured as follows:
. # Root directory
├── dist # Compiled files
├── prisma # Prisma
├── src # Source files
│ ├── contracts # Contract abi & data
│ ├── listeners # Listener module
│ ├── types # Type files
│ ├── utils # Utility files
│ │ ├── chainManager.ts # Chain manager utility
│ │ ├── messageSigning.ts # Message signing utility
│ └── index.ts # Main file
├── .env # Environment variables
To run the server, use the following command:
npm start
The listener module is responsible for listening to events emitted by the ERC20-Bridge smart contracts. It is divided into two parts: querying past events and continuous event listening.
The ERC20-Bridge Backend uses a MySQL database to store relevant data. The database is set up using Prisma. The database schema is defined in the schema.prisma
file. To update the database schema, make changes to the schema.prisma
file and run the following command:
npx prisma migrate dev
Contributions are welcome!