Keagate
🔑 Keagate is an open-source, high-performance alternative to popular cryptocurrency payment gateways such as Coinbase Commerce, CoinGate, BitPay, NOWPayments, CoinRemitter, CoinsPaid and more.
Install / Use
/learn @dilan-dio4/KeagateREADME
Keagate (ki:geɪt) – A High-Performance Cryptocurrency Payment Gateway
</h2> <!-- <h4 align="center"> <b>🚧 This project is actively in development 🚧</b> </h4> ---> <h4 align="center"> <img alt="Snyk vulnerabilities" src="https://shields.io/snyk/vulnerabilities/github/dilan-dio4/keagate?style=flat-square" /> <img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/dilan-dio4/Keagate?style=flat-square"> <img alt="GitHub top language" src="https://img.shields.io/github/languages/top/dilan-dio4/Keagate?style=flat-square"> <a href="https://gitter.im/Keagate/community?utm_source=share-link&utm_medium=link&utm_campaign=share-link"><img alt="Gitter" src="https://img.shields.io/gitter/room/dilan-dio4/Keagate?style=flat-square"></a> <a href="https://dilan-dio4.github.io/keagate-example-swagger/"><img alt="Swagger Validator" src="https://img.shields.io/swagger/valid/3.0?specUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fdilan-dio4%2Fkeagate-example-swagger%2Fmain%2Fkeagate-openapi3.json&style=flat-square"></a> </h4> <br /> <p align="center"> <img src="assets/icon-tiny.png" width="150" alt="Keagate Icon"> </p> <!-- TODO: Keagate Vector ---> <!-- TABLE OF CONTENTS -->Table of Contents
- About the Project
- Installation
- Configuration
- Payment Lifecycle
- Instant Payment Notifications
- Development
About the Project
Keagate is a self-hosted, high-performance cryptocurrency payment gateway. Payments can be administered via API for flexibility or with the built-in invoicing client (image below).
Supported currencies: Bitcoin, Ethereum, Dogecoin, Solana, Litecoin, Polygon, Dash, Ripple (coming soon), Tron (coming soon).
<p align="left"> <img src="assets/invoice-frame.png" width="600" alt="Invoice Preview"> </p>Purpose
- No KYC
- No fees, middleman, or escrow
- Self-hosted/Private
- Easily extensible
- Lightweight and highly performant
Funds go directly to your wallet via a one-time address that is generated for each payment.
Installation
<p align="left"> <a href="https://www.youtube.com/watch?v=dxMZIbeRJac"> <img src="assets/yt-screenshot.png" width="700" alt="Keagate Youtube Preview"> </a> </p>One-liner
The purpose of this installation script is to get Keagate up-and-running quickly in a Linux environment. The CLI will guide you in configuring, managing, and securing the instance.
bash -c "$(curl -sSL https://raw.githubusercontent.com/dilan-dio4/Keagate/main/packages/scripts/keagate.sh)"
Alternate:
curl -o keagate.sh https://raw.githubusercontent.com/dilan-dio4/Keagate/main/packages/scripts/keagate.sh
chmod +x keagate.sh
./keagate.sh
This helper script has been tested on...
- Ubuntu 18+
- Debian 10+
- Amazon Linux 4.14+
- CentOS 7.9+
...via AWS and Azure.
<!-- No Docker quick install on Redhat RHEL -->This script should run successfully on most flavors of Linux with some configuration. Otherwise, use the manual build, as it's fairly straightforward.
Manual Installation
Prerequisites
- MongoDB – Install
- Running on your machine OR remotely via a connection string
- Web server (like Nginx or Apache2) – Install
- Serving as a reverse proxy to
localhost:8081 8081is the default port that Keagate runs on, can be changed via the PORT configuration option.
- Serving as a reverse proxy to
- Node > 14 and NPM – Install
- Use of
nvmto manage Node and NPM is recommended
- Use of
# +++ Don't have Node?
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
nvm install 16
nvm use 16
# ---
npm i -g pnpm
pnpm setup
pnpm -g pm2
git clone https://github.com/dilan-dio4/Keagate
cd Keagate
pnpm i
pnpm run build
# +++ Configure Keagate with:
node packages/scripts/build/configure.js
# --- OR manually (see Configuration section)
pm2 start packages/backend/build/index.js --name Keagate --time
Configuration
Keagate requires some configuration. This is done via a file called local.json in /config, next to default.json. This file will automatically be used when you start Keagate. Note that parameters in local.json will overwrite those in default.json.
There are two methods to configure Keagate, and they can be used in conjunction with each other.
CLI
Keagate has a built-in CLI to build configurations in packages/scripts. After you've cloned and built the package. Head to the root Keagate directory and execute the following:
node packages/scripts/build/configure.js
Note – this CLI is automatically launched in the one-liner installation script.
The CLI will write the config/local.json file upon completion unless one already exists. In that case, it will write to config/local2.json and ask that you manually merge your new parameters, as needed.
Custom
Create or open the file local.json in /config. You can use the provided default.json file as a reference (your local.json will override these).
The schema of the Keagate configuration can be seen (in TypeScript) at packages/common/src/config.ts.
Currencies
To configure a single currency, add an object with the key of the currency's ticker with the following attributes:
Ticker can be one of 'LTC', 'BTC', 'ETH', 'DOGE', 'SOL', 'DASH', or 'MATIC'. See example.
| Key | Description | Required | Default |
|----------------------------------|----------------------------|----------------------------------|--|
| ADMIN_PUBLIC_KEY | Public key (address) of your admin wallet | Yes | null (string) |
| ADMIN_PRIVATE_KEY | Private key of admin wallet. Only needed if you plan on programmatically sending transactions | No | null (string) |
Protected options
This section details specific configuration parameters that should be handled with extra care. A malicious actor could manipulate the integrity of payments if they had access to these parameters.
There's a built-in script to securely generate and print these values at random:
node packages/scripts/build/setupSeeds.js
# OR
ts-node packages/scripts/src/setupSeeds.ts
# Prints
{
"INVOICE_ENC_KEY": "5036...9cc3",
"SEED": "eb08...3afc",
"KEAGATE_API_KEY": "9fac8f7d...c6568f97",
"IPN_HMAC_SECRET": "e50dd645...ea5baf54"
}
| Key | Description | Required | Default |
|----------------------------------|----------------------------|----------------------------------|--|
| SEED | Seed for transactional wallet generator. Must be a 128-bit hex string. Protect this value in production | Yes | null (string) |
| KEAGATE_API_KEY | Api key that will be required in administrative request's keagate-api-key header. Protect this value in production | No | 'API-KEY' (string) |
| INVOICE_ENC_KEY | Key that will be used to encrypt payment IDs when distributed via invoice. Protect this value in production | Yes | null (string) |
| IPN_HMAC_SECRET | Key of the HMAC signature that is set in the x-keagate-sig header of each POST request when using Instant Payment Notifications. Protect this value in production | No | null (string) |
Other options
| Key | Description | Required | Default |
|----------------------------------|----------------------------|----------------------------------|--|
| IP_WHITELIST | List of IP address ["1.1.1.1" , "2.2.2.2",...] to be whitelisted for administrative requests | No | [] (string[]) |
| TRANSACTION_TIMEOUT | Milliseconds by which payments will be valid for. After that, the payment is expired | No | 1200000 [20 Minutes] (number) |
| TRANSACTION_MIN_REFRESH_TIME | Minimum milliseconds by which transactions will idle between refreshes | No | 30000 [30 Seconds] (number) |
| TRANSACTION_SLIPPAGE_TOLERANCE | Percentage of a total payment that is discounted as slippage.<br /><br />Example: a TRANSACTION_SLIPPAGE_TOLERANCE of 0.02 for a 100 SOL payment will be fulfilled at 98 SOL. | No | 0.02 (number) |
| BLOCKBOOK_RETRY_DELAY | Milliseconds to wait before re-trying a failed Blockbook request. | No | 5000 (number) |
| MONGO_CONNECTION_STRING | Connection string for MongoDB instance including any authentication. | No | 'mongodb://localhost:27017' (string) |
| MONGO_KEAGATE_DB | Mongo database to use for storing/managing payments | No | 'keagate' (string) |
| IS_DEV | For development only. Turn on testnets for given currencies and activate development features | No | false (boolean) |
| HOST | Your domain or IP that Keagate is running on. This is used for aesthetics and has no functional effect on Keagate | No | null (string) |
| PORT | The port that Keagate's backend API will run on | No | 8081 (number) |
