β©οΈ
Keagate β A High-Performance Cryptocurrency Payment Gateway
π§
This project is actively in development
π§
Table of Contents
About The Project
Keagate is a self-hosted, high-performance cryptocurrency payment gateway. Payments can administer via the API or with the built-in invoicing client (image below).
Currently support currencies: Solana, Cardano, Litecoin, and Dash. (Bitcoin, Ripple coming next)
Todo: all trezor compatible chains falls to coinlib, others are built custom here.
Purpose
- No KYC
- No fees (besides network) or middleman
- Private
- Self-hosted
- Easily extensible for new currencies
- Highly performant
- No IP Blocking
Funds go directly to your wallet via the one-time addresses that are created for each payment.
Getting Started
Prerequisites
- Install Docker Compose.
git clone ...
Installation
TODO Create Dockerfile (Nginx, Mongo no external, Node, Npm)
API Providers
In order to check wallet balances and broadcast transactions, Keagate needs to interact with particular blockchain APIs. There's a variety of providers out there that support different sets of blockchains. This packages bundles up connectors to popular providers with a simple, unified API.
Existing connectors can be seen in the packages/api-providers folder. All of the one available in this package provide generous free tiers. Simply pass your API keys with the configuration below.
Currently available API providers:
Name | Available chains |
---|---|
NowNodes | dash, ltc, btc |
Tatum | ltc, btc, ada, and xrp |
It's very easy to add a provider, see TatumProvider.ts as an example.
Make sure that one of the available API providers cover each currency you plan on using.
Usage
Keagate requires some configuration. Create a file called local.json
in /config
, next to default.json
, to edit of the parameters below. Use the provided default.json
file as a reference (your local.json
will override these).
To configure a single currency, add an object with the key of the currencies ticker with the following attributes:
Key | Description | Required | Default |
---|---|---|---|
ADMIN_PUBLIC_KEY |
Public key (address) of Litecoin admin wallet | Yes | null (string) |
ADMIN_PRIVATE_KEY |
Private key of Litecoin admin wallet. Used for programmatically sending transactions from admin | No | null (string) |
PROVIDER |
The id of a provider in packages/api-providers. |
Yes except SOL | null (AvailableProvider) |
PROVIDER_PARAMS |
Parameters for a particular provider's constructor. Could be [API_KEY, REGION] like Tatum | No | null (string[]) |
Other root configuration options:
Key | Description | Required | Default |
---|---|---|---|
KEAGATE_API_KEY |
Custom key that will be required in the administrative requests keagate-api-key requests to Keagate |
No | null (string) |
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 for which a transaction will be valid for | No | 1200000 [20 Minutes] (number) |
TRANSACTION_REFRESH_TIME |
Milliseconds for which each active transaction will be re-scanned | No | 10000 [10 Seconds] (number) |
TRANSACTION_SLIPPAGE_TOLERANCE |
Percentage of a payment that discounted as from a total payment. Example: a TRANSACTION_SLIPPAGE_TOLERANCE of 0.02 for a 100 SOL payment will be fulfilled at 98 SOL. |
No | 0.02 (number) |
MONGO_CONNECTION_STRING |
Connection string for mongodb instance, which is installed automatically with docker | No | mongodb://localhost:27017 (string) |
MONGO_KEAGATE_DB |
Mongo database to use for storing/managing payments | No | keagate (string) |
USE_SO_CHAIN |
SoChain is a free blockchain infrastructure API for that allows for 300 requests/minute free-of-charge. Setting this to true will utilize SoChain for part of the btc, dash, and ltc payment process. Recommended |
No | true (boolean) |
TESTNETS |
For development only. Turn on testnets for given currencies | No | false (boolean) |
Your config/local.json
could look something like:
{
"dash": {
"ADMIN_PUBLIC_KEY": "MY_WALLET_ADDRESS",
"ADMIN_PRIVATE_KEY": "MY_PRIVATE_KEY",
"PROVIDER": "NowNodes",
"PROVIDER_PARAMS": ["MY_API_KEY"]
},
"KEAGATE_API_KEY": "abcd123",
"IP_WHITELIST": ["1.1.1.1","2.2.2.2"]
// ...
}
Development
Development experience and extensibility are a high priority for this package.
- Git clone this package.
cd Keagate && npm i
- Add a mongoDB connection to the
MONGO_CONNECTION_STRING
attribute inconfig/local.json
along with some admin wallet credentials. For development, the Mongo Atlas free tier works great. npm run dev
to start the invoice client and backend.- Any changes in
packages/invoice-client/src
will be automatically reflected on refresh. - Any changes to the source of
packages/backend/src
will be reflected automatically viats-node-dev
.
- Any changes in
Adding a currency
There's four steps in adding a currency to this package.
- Add the ticker, along with some metadata, to the currencies type in packages/common/src/currencies.ts.
- Create the admin wallet. This is where payments are finally sent to and presumably the real wallet of the client. Note that the admin wallet can also be used to programmatically send transactions as well.
- Start by taking a look at Solana's admin wallet and note that you only need to implement two functions:
getBalance
andsendTransaction
. The class that admin wallets inherit from, GenericAdminWallet, handles class inheritance.
- Start by taking a look at Solana's admin wallet and note that you only need to implement two functions:
- Create the transactional wallet. This class can be thought of a payment, since a new transactional wallet is created for every payment, along with a new Public Key and Private Key. Transactional wallets, and their associated payment data, are stored in Mongo.
- Start by taking a look at Solana's transactional wallet and note that you only need to implement three functions:
fromNew
,getBalance
and_cashOut
. The class that transactional wallets inherit from, GenericTransactionalWallet, handles the rest.
- Start by taking a look at Solana's transactional wallet and note that you only need to implement three functions:
- Add both the transactional and admin wallet classes to packages/backend/src/currenciesToWallets.ts so it can be referred to by ticker across the project
And that's it! Start the dev environment and create a new payment of any amount with your new ticker.
Adding an API route
Customizing the invoice interface
The invoice client is a statically built React package (via Vite). This static build is served in backend
. This functionality can be seen here.
Editing the react package will automatically build to dist
, so just refresh the page to see the changes.
The source code in invoice client is pretty straight-forward, so anyone familiar with React (& TailwindCSS) should have an easy time making their desired alterations.
Adding a blockchain API provider
The invoice client is a statically built React package (via Vite). This static build is served in backend
. This functionality can be seen here.
Editing the react package will automatically build to dist
, so just refresh the page to see the changes.
The source code in invoice client is pretty straight-forward, so anyone familiar with React (& TailwindCSS) should have an easy time making their desired alterations.