Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/web3batman/rune-airdrop-backend

Rune Airdrop Backend (This ๐Ÿ“ฆ repository contains the backend ๐Ÿงฉ services for the ๐Ÿ… Rune Airdrop ๐ŸŽ project, featuring a Swagger UI ๐Ÿ“š for API ๐Ÿ› ๏ธ documentation ๐Ÿ“„ and ๐Ÿงช testing)
https://github.com/web3batman/rune-airdrop-backend

airdrop backend bitcoin bitcoinjs express mongodb mongoose rune typescript

Last synced: about 1 month ago
JSON representation

Rune Airdrop Backend (This ๐Ÿ“ฆ repository contains the backend ๐Ÿงฉ services for the ๐Ÿ… Rune Airdrop ๐ŸŽ project, featuring a Swagger UI ๐Ÿ“š for API ๐Ÿ› ๏ธ documentation ๐Ÿ“„ and ๐Ÿงช testing)

Awesome Lists containing this project

README

        

---

# Mystic Runestone Airdrop Tool Backend

## Overview

The Runestone Airdrop Backend is a server application that facilitates the airdrop of Runestone tokens. The backend is developed using Node.js and Express.js and includes API endpoints for various functionalities such as redeeming fees, estimating transaction fees, and managing different amounts for airdrops. The project also integrates Swagger UI for API documentation.

## Project Structure

```
root/
โ”œโ”€โ”€ config/
โ”‚ โ””โ”€โ”€ config.ts
โ”œโ”€โ”€ routes
โ”‚ โ””โ”€โ”€ AirdropRoute
โ”‚ โ”œโ”€โ”€ different-amount.route.ts
โ”‚ โ”œโ”€โ”€ large-different-amount.route.ts
โ”‚ โ”œโ”€โ”€ large-different-amount-airdrop.route.ts
โ”‚ โ”œโ”€โ”€ same-amount.route.ts
โ”‚ โ””โ”€โ”€ EstimateRoute
โ”‚ โ”œโ”€โ”€ different-amount-estimate.route.ts
โ”‚ โ”œโ”€โ”€ same-amount-estimate.route.ts
โ”‚ โ””โ”€โ”€ SubRoute
โ”‚ โ””โ”€โ”€ runestone-fee.route.ts
โ”œโ”€โ”€ service/
โ”‚ โ””โ”€โ”€ psbt/
โ”‚ โ”œโ”€โ”€ CreateAirdropRunestonePsbt.ts
โ”‚ โ”œโ”€โ”€ redeemRunestoneAmountRunestone.ts
โ”‚ โ”œโ”€โ”€ redeemRunestoneSameAmount.ts
โ”‚ โ”œโ”€โ”€ RuneOne.ts
โ”‚ โ”œโ”€โ”€ RuneSub.ts
โ”‚ โ””โ”€โ”€ SameAmountEstimate.ts
โ”œโ”€โ”€ test/
โ”‚ โ”œโ”€โ”€ CreateTest.ts
โ”‚ โ”œโ”€โ”€ freeTierAirdrop.ts
โ”‚ โ”œโ”€โ”€ matchTests.ts
โ”‚ โ””โ”€โ”€ MWtests.ts
โ”œโ”€โ”€ utils/
โ”‚ โ”œโ”€โ”€ blockcypher.api.ts
โ”‚ โ”œโ”€โ”€ mempool.api.ts
โ”‚ โ”œโ”€โ”€ TS
โ”‚ โ”‚ โ”œโ”€โ”€ mw.ts
โ”‚ โ”‚ โ””โ”€โ”€ TsUtils.ts
โ”‚ โ””โ”€โ”€ unisat.api.ts
โ”œโ”€โ”€ .env.example
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ swagger.yaml
โ”œโ”€โ”€ tsconfig.json
โ””โ”€โ”€ yarn.lock
env
```

## Installation

1. Clone the repository:

```
git clone git clone https://github.com/leionion/rune-airdrop-backend.git
cd rune-airdrop-backend
```

2. Install dependencies:

```
yarn install
```

3. Create a `.env` file:

```
cp .env.example .env
```

4. Configure the environment variables in `.env` file:
```
PORT=your-port
```

## Usage

1. Start the server:

```
yarn dev
```

2. The server should be running on the specified port. You can visit `http://localhost:[PORT]` to check if the server is up and running.

3. Access the API documentation via Swagger UI at `http://localhost:[PORT]/api-docs`.

## API Endpoints

Here are some key API endpoints provided by the backend:

- **GET /**: Check if the backend server is running.
- **POST /api/redeem-fee**: Redeem Runestone fees.
- **POST /api/same-amount**: Handle airdrops with the same amount.
- **POST /api/different-amount**: Handle airdrops with different amounts.
- **POST /api/large-different-amount**: Handle large different amount airdrops.
- **POST /api/large-different-amount-airdrop**: Handle large airdrop transactions with different amounts.
- **POST /api/estimate/same-amount**: Estimate transaction fee for same amount airdrop.
- **POST /api/estimate/different-amount**: Estimate transaction fee for different amount airdrop.

## Middleware

- **CORS**: Cross-Origin Resource Sharing is enabled using the `cors` package.
- **Body-Parser**: JSON and URL-encoded data parsing with `body-parser` and `express.json`.

## Swagger

Swagger UI is integrated to provide interactive API documentation. The `swagger.yaml` file is required to configure API documentation, which can be accessed at `/api-docs`.

## Mutex

Mutex from `async-mutex` is used for API rate limit protection functionality.

## Global Variables

- `app.locals.walletIndex`: Global iterator for wallet management.
- `app.locals.iterator`: Global iterator for unisat API distribution.

## Swagger Usage

### Base URL

The base URL for the API is:

- Development: `http://localhost:5000/api`
- Production: `https://rune-airdrop-backend.onrender.com/api`

### Endpoints

#### Different Amount Rune Airdrop

- **Description:** Transfer different amounts of Rune tokens to different addresses
- **Endpoint:** `/different-amount`
- **HTTP Method:** POST

#### Large Different Amount Rune Airdrop

- **Description:** Transfer different amounts of Rune tokens to different addresses (for a large number of addresses)
- **Endpoint:** `/large-different-amount`
- **HTTP Method:** POST

#### Large Different Amount Rune Airdrop (Execute)

- **Description:** Execute the large different amount Rune Airdrop with a pre-generated transaction ID
- **Endpoint:** `/large-different-amount-airdrop`
- **HTTP Method:** POST

#### Same Amount Rune Airdrop

- **Description:** Transfer the same amount of Rune tokens to different addresses
- **Endpoint:** `/same-amount`
- **HTTP Method:** POST

#### Calculate Runestone Transaction Fee

- **Description:** Calculate the fee for a runestone transaction
- **Endpoint:** `/runestone-fee`
- **HTTP Method:** GET

#### Estimate Different Amount Rune Airdrop

- **Description:** Estimate the different amount Rune Airdrop
- **Endpoint:** `/estimate/different-amount`
- **HTTP Method:** POST

#### Estimate Same Amount Rune Airdrop

- **Description:** Estimate the same amount Rune Airdrop
- **Endpoint:** `/estimate/same-amount`
- **HTTP Method:** POST

### Error Handling

In case of errors, the API responds with appropriate HTTP status codes along with error messages in the response body.