Skip to content

Crossbell-Box/operator-sign

Repository files navigation

Crossbell Operator Sign Backend Service

Operator Sign (Op Sign) designed to enhance the user experience on the Crossbell network. Its primary goal is to streamline the interaction process by minimizing the number of manual approvals required for each transaction.

Features

  • Efficient Interactions: No need to manually approve every transaction, ensuring a smoother user experience.
  • Secure Authentication: Leverage the SIWE protocol to authenticate users based on their encrypted signature.
  • Delegated Operations: The Operator contract methods can carry out operations on the user's behalf, ensuring both convenience and security.

Getting Started

Install deps:

npm install

Prepare environment variables:

copy .env.example .env

Setup wallet:

You will need to create a wallet and obtain the private key and address, then fill in the environment variables: OP_SIGN_OPERATOR_WALLET_ADDRESS and OP_SIGN_OPERATOR_WALLET_PRIVATE_KEY.

Start Database instance:

npm run docker:db

Migrate database and generate types in development environment:

npm run prisma:migrate:dev

Start server:

npm run start:dev

Access the Swagger API docs:

Once the server starts, the Swagger API docs will be available at the /docs path. For example, if you are running the server locally at port 3988, you can access the docs at http://localhost:3988/docs.

Deployment

Docker:

# building new NestJS docker image
docker-compose build
# or
npm run docker:build

# start docker-compose
docker-compose up -d
# or
npm run docker

In Node.js Environment:

npm install
npm run build
NODE_ENV=production node dist/main

Migrate database

In development:

npm run prisma:migrate:dev

In production:

npm run prisma:migrate:deploy

Customizing Endpoints in Crossbell React Kits

Check out the customizing guide here.

Modules

The Siwe module is designed to facilitate the implementation of the Sign-In with Ethereum (SIWE) protocol. It encompasses a suite of functions essential for integrating SIWE's authentication mechanisms.

The SiweTransaction module is responsible for managing a range of transactions, including posting, commenting, liking, and tipping activities.

The EventListeners module is crafted to monitor and process events generated by the Operator contract. It ensures the system responds appropriately to permissions updates and other significant contract interactions.

The CsbManager module provides utility functions that are instrumental for managing interactions with the $CSB.

The Contract module used to initialize the contract instance.

Feedback & Contributions

We welcome feedback and contributions from the community. Feel free to raise issues, submit pull requests, or share your insights to enhance the Operator Sign feature.

🫡 This project was initially developed by @SongKeys. Original commit logs were deleted to protect sensitive information before open-sourcing.