Multipay is a multi cryptocurrency payment gateway as a microservice that facilitates the creation and management of wallets, balance checking, and payment verification and confirmation for various cryptocurrencies. It leverages Trust Wallet Core for wallet functionalities and uses gRPC for and graphQL for payment management.
- ✅ Tron
- ✅ Ethereum
- ✅ Binance smart chain
- ✅ Pactus
- ✅ USDT TRC-20
- ✅ USDT BEP-20
- multipay
-
Clone the repository:
git clone https://github.com/yahya-aghdam/multipay.git cd multipay
-
Install dependencies:
npm install
-
Build the project:
npm run build
-
Start the server:
npm start
PROTO_URL=your_proto_url
PROTO_PORT=your_proto_port
GRAPHQL_PORT=your_graphql_port
DB_URL=your_db_url
DB_NAME=your_db_name
PAYMENT_EXPIRATION_TIME_MIN=your_payment_expiration_time # in minutes
WALLET_STRENGTH=your_wallet_strength # in bits
ETHER_SCAN_API_KEY=your_ether_scan_api_key # if you support Ethereum sign in https://etherscan.io and paste your api key in here
BSC_SACN_API_KEY=your_bsc_sacn_api_key # if you support Binance Smart Chain sign in https://bscscan.com and paste your api key in here
Based on DB_URL
variable in .env
file, multipay can use MySQL, PostgreSQL or MongoDB.
- ✅ MySQL
- ✅ PostgreSQL
- ✅ MongoDB
Database connection URL:
Type | default connection url |
---|---|
mongo | mongodb://127.0.0.1:27017 |
mysql | mysql://root@127.0.0.1:3306 |
postgresql | postgresql://postgres@127.0.0.1:5432 |
You can add your own custom coins in src/balance/index.ts
file.
To start the development server locally, with hot reloading:
npm run dev
To start the development server using Docker:
npm run docker:dev
To start the production server locally:
npm run build
npm run start
To start the production server using Docker:
npm run docker:build
You can use this invitation link to test app: Postman example
Coin name | Type | value |
---|---|---|
Tron (TRX) | string |
tron |
Ethereum (ETH) | string |
ethereum |
Binance smart chain (BNB) | string |
smartchain |
Pactus (PAC) | string |
pactus |
USDT TRC-20 (USDT) | string |
usdt_trc20 |
USDT BEP-20 (USDT) | string |
usdt_bep20 |
Message body:
Field | Type | Description |
---|---|---|
amount |
string |
Amount of payment like "0.00256" |
clientId |
string |
ID of client |
coin |
string |
Name of coin like "etherum" |
Response:
{
"coin": "ethereum",
"amount": "0.001",
"expiration": "1742146248273",
"paymentId": "53d10ad5-3be0-4ef3-ac30-6a88afb4e364",
"clientId": "testClientId",
"address": "0xFF49d5Ff0Da6cB8825ba644F0262a514Ec7830C0",
"time": "1742145048273"
}
Message body:
Field | Type | Description |
---|---|---|
paymentId |
string |
ID of payment |
Response:
{
"coin": "ethereum",
"amount": "0.001",
"expiration": "1742146248273",
"paymentId": "53d10ad5-3be0-4ef3-ac30-6a88afb4e364",
"clientId": "testClientId",
"address": "0xFF49d5Ff0Da6cB8825ba644F0262a514Ec7830C0",
"isPaid": true,
"isConfirmed": true,
}
The GraphQL schema defines the types and operations available in the API. Here are the main types and operations:
type Payment {
_id: String!
paymentId: String!
coin: String!
amount: String!
expiration: String!
clientId: String!
address: String!
isPaid: Boolean!
blockNumber: Int!
isConfirmed: Boolean!
time: String!
}
type Payment_CreatePaymentOutput {
paymentId: String!
coin: String!
amount: String!
expiration: String!
clientId: String!
address: String!
time: String!
}
type Payment_VerifyPaymentOutput {
coin: String!
amount: String!
expiration: String!
paymentId: String!
clientId: String!
address: String!
isPaid: Boolean!
isConfirmed: Boolean!
}
type Wallet {
_id: String!
address: String!
mnemonic: String!
coin: String!
amount: String!
}
type Query {
payments: [Payment!]!
paymentById(paymentId: String!): Payment
}
type Query {
wallets: [Wallet!]!
walletBy(address: String,coin: String): [Wallet!]!
}
type Mutation {
createPayment(
coin: String!
amount: String!
clientId: String!
): Payment_CreatePaymentOutput!
verifyPayment(
paymentId: String!
): Payment_VerifyPaymentOutput!
}
query {
payments {
_id
paymentId
coin
amount
expiration
clientId
address
isPaid
blockNumber
isConfirmed
time
}
}
query {
paymentById(paymentId: "your_payment_id") {
_id
paymentId
coin
amount
expiration
clientId
address
isPaid
blockNumber
isConfirmed
time
}
}
mutation {
createPayment(
coin: "ethereum",
amount: "0.001",
clientId: "testClientId"
) {
paymentId
coin
amount
expiration
clientId
address
time
}
}
mutation {
verifyPayment(paymentId: "your_payment_id") {
coin
amount
expiration
paymentId
clientId
address
isPaid
isConfirmed
}
}
query WalletBy {
wallets {
_id
address
mnemonic
coin
amount
}
}
query WalletBy {
walletBy(coin: "ethereum") {
_id
address
mnemonic
coin
amount
}
}
src/
├── config/ # Configuration files
│ ├── constants.ts # Application constants
│ └── dotenv.ts # Environment variable configuration
├── db/ # Database related code
│ ├── entity.ts # Database entities
│ └── mikro_orm.ts # MikroORM configuration
├── lib/ # Core library code
│ ├── balance/ # Balance checking functionality
│ │ ├── index.ts # Main balance logic
│ │ ├── utils.ts # Utility functions for balance
│ │ └── vars.ts # Variables for balance logic
│ └── wallet/ # Wallet management
│ ├── index.ts # Main wallet logic
│ └── utils.ts # Utility functions for wallet
├── protos/ # gRPC protocol definitions
│ ├── multipay.proto # Protocol buffer definition
│ └── multipay.service.proto.ts # Generated gRPC service
├── graphql/ # GraphQL schema and resolvers
│ ├── schema.ts # GraphQL schema definition
│ └── resolvers.ts # GraphQL resolvers
├── services/ # Business logic services
│ ├── payment.service.ts # Payment-related logic
│ └── wallet.service.ts # Wallet-related logic
├── utils/ # General utility functions
│ ├── logger.ts # Logging utility
│ └── helpers.ts # Helper functions
└── index.ts # Application entry point
This project is licensed under the MIT License - see the LICENSE file for details.