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.
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
-
Clone the repository:
git clone git clone https://github.com/leionion/rune-airdrop-backend.git cd rune-airdrop-backend
-
Install dependencies:
yarn install
-
Create a
.env
file:cp .env.example .env
-
Configure the environment variables in
.env
file:PORT=your-port
-
Start the server:
yarn dev
-
The server should be running on the specified port. You can visit
http://localhost:[PORT]
to check if the server is up and running. -
Access the API documentation via Swagger UI at
http://localhost:[PORT]/api-docs
.
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.
- CORS: Cross-Origin Resource Sharing is enabled using the
cors
package. - Body-Parser: JSON and URL-encoded data parsing with
body-parser
andexpress.json
.
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 from async-mutex
is used for API rate limit protection functionality.
app.locals.walletIndex
: Global iterator for wallet management.app.locals.iterator
: Global iterator for unisat API distribution.
The base URL for the API is:
- Development:
http://localhost:5000/api
- Production:
https://rune-airdrop-backend.onrender.com/api
- Description: Transfer different amounts of Rune tokens to different addresses
- Endpoint:
/different-amount
- HTTP Method: POST
- Description: Transfer different amounts of Rune tokens to different addresses (for a large number of addresses)
- Endpoint:
/large-different-amount
- HTTP Method: POST
- Description: Execute the large different amount Rune Airdrop with a pre-generated transaction ID
- Endpoint:
/large-different-amount-airdrop
- HTTP Method: POST
- Description: Transfer the same amount of Rune tokens to different addresses
- Endpoint:
/same-amount
- HTTP Method: POST
- Description: Calculate the fee for a runestone transaction
- Endpoint:
/runestone-fee
- HTTP Method: GET
- Description: Estimate the different amount Rune Airdrop
- Endpoint:
/estimate/different-amount
- HTTP Method: POST
- Description: Estimate the same amount Rune Airdrop
- Endpoint:
/estimate/same-amount
- HTTP Method: POST
In case of errors, the API responds with appropriate HTTP status codes along with error messages in the response body.