Swypt Logo
Swypt Logo
/API Docs

Swypt API Documentation

This documentation covers integration with Swypt APIs and smart contract functions for on-ramp and off-ramp operations — enabling conversion between fiat currencies (KES) and cryptocurrencies across multiple blockchain networks.

On-Ramp

Convert fiat (KES) to crypto via M-Pesa STK Push, then receive tokens on-chain.

Off-Ramp

Send crypto to the Swypt escrow contract and receive fiat (KES) via M-Pesa.

Multi-Chain

Supports Polygon, Lisk, Celo, Base, Scroll, and Algorand networks.

Authentication

All API endpoints require these headers on every request:

x-api-keyYour API key
x-api-secretYour API secret

Deployed Contracts

Algorand

Supported Asset

USDC — Asset ID: 31566704

Smart Contract ABI

For interacting with Swypt smart contracts on EVM chains, you'll need the contract ABI (Application Binary Interface).

Algorand uses native blockchain transactions and does not require an ABI. See the Algorand-specific sections below for integration details.

Key Functions for Integration

withdrawToEscrowStandard withdrawal (requires prior token approval). Returns a nonce.
viewDepositWithNonceView withdrawal details by nonce — token, user, amount, exchange rate, fee.
depositToWalletDeposit tokens to a user's wallet address.
refundUserRefund a user's token amount back to their address.
javascript
export const SWYPT_CONTRACT_ABI = [
  { inputs: [], stateMutability: 'nonpayable', type: 'constructor' },
  { inputs: [], name: 'AccessControlBadConfirmation', type: 'error' },
  {
    inputs: [
      { internalType: 'address', name: 'account', type: 'address' },
      { internalType: 'bytes32', name: 'neededRole', type: 'bytes32' },
    ],
    name: 'AccessControlUnauthorizedAccount',
    type: 'error',
  },
  // ... (see full ABI below)
  {
    inputs: [
      { internalType: 'address', name: '_tokenAddress', type: 'address' },
      { internalType: 'uint256', name: '_amount', type: 'uint256' },
      { internalType: 'uint256', name: '_feeAmount', type: 'uint256' },
    ],
    name: 'withdrawToEscrow',
    outputs: [{ internalType: 'uint256', name: 'nonce', type: 'uint256' }],
    stateMutability: 'payable',
    type: 'function',
  },
  {
    inputs: [{ internalType: 'uint256', name: '_nonce', type: 'uint256' }],
    name: 'viewDepositWithNonce',
    outputs: [
      { internalType: 'address', name: 'token', type: 'address' },
      { internalType: 'address', name: 'user', type: 'address' },
      { internalType: 'uint256', name: 'amount', type: 'uint256' },
      { internalType: 'uint256', name: 'exchangeRate', type: 'uint256' },
      { internalType: 'uint256', name: 'feeAmount', type: 'uint256' },
    ],
    stateMutability: 'view',
    type: 'function',
  },
  { stateMutability: 'payable', type: 'receive' },
];

Getting Quotes

Before performing any on-ramp or off-ramp operations, get a quote to determine rates, fees, and expected output amounts.

Get Quote

POSThttps://pool.swypt.io/api/fx-quotes
ParameterDescriptionRequiredExample
typeType of operationYes"onramp" | "offramp"
amountFiat amount to convert (onramp)Yes*"10"
fiatAmountFiat output amount (offramp)Yes*"1000"
fiatCurrencyFiat currency codeYes"KES"
cryptoCurrencyCryptocurrency symbolYes"USDT"
networkBlockchain networkYes"celo"
categoryTransaction category (offramp only)No"B2C"

Example — Onramp (KES → USDT)

javascript
const response = await axios.post('https://pool.swypt.io/api/fx-quotes', {
  type: "onramp",
  amount: "10",
  fiatCurrency: "KES",
  cryptoCurrency: "USDT", // cKES, USDC
  network: "celo"
}, {
  headers: {
    'x-api-key': 'YOUR_API_KEY',
    'x-api-secret': 'YOUR_API_SECRET'
  }
});

Response:

json
{
  "statusCode": 200,
  "message": "Quote retrieved successfully",
  "data": {
    "inputAmount": "10",
    "outputAmount": 0.07720588232186155,
    "inputCurrency": "KES",
    "outputCurrency": "USDT",
    "exchangeRate": 129.52380957595,
    "type": "onramp",
    "network": "scroll",
    "fee": {
      "feeInKES": 0,
      "estimatedOutputKES": 10
    },
    "requestedAmount": "10",
    "requestedCurrency": "KES",
    "limits": {
      "min": 1,
      "max": 250000,
      "currency": "KES"
    }
  }
}

Example — Offramp (USDT → KES)

javascript
const response = await axios.post('https://pool.swypt.io/api/fx-quotes', {
  type: "offramp",
  fiatAmount: "1000",
  cryptoCurrency: "USDT",
  fiatCurrency: "KES",
  network: "scroll",
  category: "B2C"
}, {
  headers: {
    'x-api-key': 'YOUR_API_KEY',
    'x-api-secret': 'YOUR_API_SECRET'
  }
});

Response:

json
{
  "statusCode": 200,
  "message": "Quote retrieved successfully",
  "data": {
    "inputAmount": "7.78167726",
    "outputAmount": "1000",
    "inputCurrency": "USDT",
    "outputCurrency": "KES",
    "exchangeRate": 128.50695000519,
    "type": "offramp",
    "network": "scroll",
    "fee": {
      "amount": "0.100368",
      "currency": "USDT",
      "feeInKes": 13,
      "estimatedOutputKES": 987,
      "decimals": 6
    },
    "requestedAmount": "1000",
    "requestedCurrency": "KES",
    "limits": {
      "min": 10,
      "max": 100000,
      "currency": "KES"
    }
  }
}

Example — Algorand Offramp (USDC → KES)

javascript
const response = await axios.post('https://pool.swypt.io/api/fx-quotes', {
  type: "offramp",
  fiatAmount: "1000",
  cryptoCurrency: "USDC",
  fiatCurrency: "KES",
  network: "algorand",
  category: "B2C"
}, {
  headers: {
    'x-api-key': 'YOUR_API_KEY',
    'x-api-secret': 'YOUR_API_SECRET'
  }
});

Error Responses

json
{ "status": "error", "message": "API key and secret are required" }
json
{ "status": "error", "message": "Invalid API credentials" }
json
{ "statusCode": 400, "message": "Invalid network", "error": "Unsupported network. Supported networks: Lisk, celo, Base, Polygon, algorand" }

Supported Assets

GEThttps://pool.swypt.io/api/listed-assets

Retrieve all supported assets, networks, and currencies.

javascript
const response = await axios.get('https://pool.swypt.io/api/listed-assets', {
  headers: {
    'x-api-key': 'YOUR_API_KEY',
    'x-api-secret': 'YOUR_API_SECRET'
  }
});

Response:

json
{
  "networks": ["lisk", "celo", "base", "polygon", "scroll", "algorand"],
  "fiat": ["KES", "USD"],
  "crypto": {
    "lisk": [
      { "symbol": "USDT", "name": "Tether LISK", "decimals": 6, "address": "0x05D032ac25d322df992303dCa074EE7392C117b9" },
      { "symbol": "ETH", "name": "Ethereum", "decimals": 18, "address": "0x0000000000000000000000000000000000000000" }
    ],
    "celo": [
      { "symbol": "USDT", "name": "Tether Celo", "decimals": 6, "address": "0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e" },
      { "symbol": "cKES", "name": "Celo Kenyan Shilling", "decimals": 18, "address": "0x456a3D042C0DbD3db53D5489e98dFb038553B0d0" },
      { "symbol": "USDC", "name": "USDC", "decimals": 6, "address": "0xcebA9300f2b948710d2653dD7B07f33A8B32118C" },
      { "symbol": "CELO", "name": "Celo", "decimals": 18, "address": "0x471EcE3750Da237f93B8E339c536989b8978a438" }
    ],
    "base": [
      { "symbol": "USDC", "name": "USDC", "decimals": 6, "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" },
      { "symbol": "ETH", "name": "ETH", "decimals": 18, "address": "0x0000000000000000000000000000000000000000" }
    ],
    "polygon": [
      { "symbol": "USDT", "name": "Tether Polygon", "decimals": 6, "address": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F" },
      { "symbol": "USDC", "name": "USD Coin Polygon", "decimals": 6, "address": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174" },
      { "symbol": "MATIC", "name": "Polygon", "decimals": 18, "address": "0x0000000000000000000000000000000000000000" }
    ],
    "scroll": [
      { "symbol": "USDT", "name": "Tether scroll", "decimals": 6, "address": "0xf55BEC9cafDbE8730f096Aa55dad6D22d44099Df" },
      { "symbol": "ETH", "name": "ETH", "decimals": 18, "address": "0x0000000000000000000000000000000000000000" }
    ],
    "algorand": [
      { "symbol": "USDC", "name": "USD Coin", "decimals": 6, "assetId": 31566704, "address": "31566704" }
    ]
  }
}

Off-Ramp Flow

The Swypt offramp involves two steps:

  1. Execute a blockchain transaction (smart contract for EVM chains, native transfer for Algorand)
  2. Call the Swypt offramp API endpoint with the transaction details

EVM Offramp — withdrawToEscrow

Performs a token withdrawal to escrow. Requires prior token approval.

_tokenAddressToken contract address
_amountPlusfeeTotal withdrawal amount including fees
_feeAmountFee amount in crypto (from fee.amount in fx-quote response)
javascript
// STEP 1: Approve contract
const contractAddress = "0x2816a02000B9845C464796b8c36B2D5D199525d5"; // Lisk
const tokenAddress = "0x05D032ac25d322df992303dCa074EE7392C117b9"; // USDT on Lisk

const amount = parseUnits(amountPlusFee.toString(), tokenDecimals);
const feeAmount = parseUnits(fee.toString(), tokenDecimals);

await token.approve(contractAddress, amount);

// STEP 2: Perform withdrawal
const tx = await contract.withdrawToEscrow(tokenAddress, amount, feeAmount);

Algorand Offramp — Native USDC Transfer

For Algorand, users send USDC directly to the Swypt hot wallet using a standard Algorand asset transfer.

Prerequisites: User must be opted into USDC (Asset ID: 31566704), have sufficient ALGO for fees (~0.001 ALGO), and have sufficient USDC balance.
javascript
import algosdk from 'algosdk';

const algodClient = new algosdk.Algodv2('', 'https://mainnet-api.algonode.cloud', 443);

const SWYPT_WALLET = 'XEI2YQ47YAEDJEOYE3KQTYJNRCA2G2TO7U4STRYMOOXAZMIHRQ7HEEPGOE';
const USDC_ASSET_ID = 31566704;

const suggestedParams = await algodClient.getTransactionParams().do();

// Convert to base units (USDC has 6 decimals): 1 USDC = 1,000,000 base units
const amountInBaseUnits = Math.floor(totalUSDC * 1_000_000);

const txn = algosdk.makeAssetTransferTxnWithSuggestedParamsFromObject({
  sender: userAddress,
  receiver: SWYPT_WALLET,
  amount: amountInBaseUnits,
  assetIndex: USDC_ASSET_ID,
  suggestedParams: suggestedParams,
  note: new Uint8Array(Buffer.from('Swypt Offramp'))
});

const signedTxn = await wallet.signTransaction(txn);
const { txId } = await algodClient.sendRawTransaction(signedTxn).do();

// Wait for confirmations (~10 seconds)
await algosdk.waitForConfirmation(algodClient, txId, 4);

Initiate Offramp Transaction

POSThttps://pool.swypt.io/api/offramp-orders
ParameterDescriptionRequiredExample
chainBlockchain networkYes"celo" | "algorand"
hashTransaction hash (66 chars EVM, 52 chars Algorand)Yes"0x80856f..."
partyBRecipient phone numberYes"254703710518"
tokenAddressToken address or asset IDYes"0x48065fbBE..." | "31566704"
projectYour project name (required for identifying pending/failed tx)Yes"project-mocha"
userAddressUser's wallet addressYes"0x98e35888..."

Example (EVM)

javascript
const response = await axios.post('https://pool.swypt.io/api/offramp-orders', {
  chain: "celo",
  hash: "0x80856f025035da9387873410155c4868c1825101e2c06d580aea48e8179b5e0b",
  partyB: "254703710518",
  tokenAddress: "0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e",
  project: "project-mocha",
  userAddress: "0x98e35888468c07320e1061eB8F5D6Bb7dc491b7c"
}, {
  headers: { 'x-api-key': 'YOUR_API_KEY', 'x-api-secret': 'YOUR_API_SECRET' }
});

Example (Algorand)

javascript
const response = await axios.post('https://pool.swypt.io/api/offramp-orders', {
  chain: "algorand",
  hash: "YQTZJW7RKT6JARGNE5XVO4GI7GZWNLTEVDGB24RG6ZLG6OG5PO4Q",
  partyB: "254703710518",
  tokenAddress: "31566704",
  project: "project-mocha",
  userAddress: "XEI2YQ47YAEDJEOYE3KQTYJNRCA2G2TO7U4STRYMOOXAZMIHRQ7HEEPGOE"
}, {
  headers: { 'x-api-key': 'YOUR_API_KEY', 'x-api-secret': 'YOUR_API_SECRET' }
});

Successful Response

json
{
  "status": "success",
  "message": "Withdrawal payment initiated successfully",
  "data": {
    "orderID": "WD-xsy6e-HO"
  }
}

Check Offramp Status

GEThttps://pool.swypt.io/api/offramp-order-status/:orderID
javascript
const response = await axios.get('https://pool.swypt.io/api/offramp-order-status/WD-xsy6e-HO', {
  headers: { 'x-api-key': 'YOUR_API_KEY', 'x-api-secret': 'YOUR_API_SECRET' }
});

Possible Status Values

PENDINGSUCCESSFAILED

Response — Success:

json
{
  "status": "success",
  "data": {
    "status": "SUCCESS",
    "message": "Withdrawal completed successfully",
    "details": {
      "phoneNumber": "254703710518",
      "ReceiverPartyPublicName": "254703710518 - Henry Kariuki Nyagah",
      "transactionSize": "20.00",
      "transactionSide": "withdraw",
      "initiatedAt": "2025-02-02T12:45:21.859Z",
      "mpesaReceipt": "TB21GOZTI9",
      "completedAt": "2025-02-02T15:45:23.000Z"
    }
  }
}

Response — Pending:

json
{
  "status": "success",
  "data": {
    "status": "PENDING",
    "message": "Your withdrawal is being processed",
    "details": {
      "phoneNumber": "254703710518",
      "transactionSize": "20.00",
      "initiatedAt": "2025-02-02T12:45:21.859Z"
    }
  }
}

Response — Failed:

json
{
  "status": "success",
  "data": {
    "status": "FAILED",
    "message": "Withdrawal failed",
    "details": {
      "phoneNumber": "254703710518",
      "transactionSize": "20.00",
      "initiatedAt": "2025-02-02T12:45:21.859Z",
      "failureReason": "Transaction timeout",
      "resultCode": "1234"
    }
  }
}

Create Offramp Ticket

POSThttps://pool.swypt.io/api/offramp-ticket

Create a support ticket for failed or pending offramp transactions.

ParameterDescriptionRequiredExample
orderIDID of failed/pending transactionNo*"WD-xsy6e-HO"
phoneUser's phone numberYes**"254703710518"
amountCrypto amountYes**"100"
descriptionTicket descriptionYes**"Failed withdrawal"
sideTransaction sideYes**"off-ramp"
userAddressUser's blockchain addressYes**"0x742d35..."
symbolToken symbolYes**"USDT"
tokenAddressToken contract address or asset IDYes**"0xc2132D05..."
chainBlockchain networkYes**"Polygon"
* Either provide orderID OR all other required fields.
** Required only when orderID is not provided. Both failed and pending transactions can use orderID.

From Failed Transaction

javascript
const response = await axios.post('https://pool.swypt.io/api/offramp-ticket', {
  orderID: "WD-xsy6e-HO",
  description: "Refund for failed withdrawal"
}, {
  headers: { 'x-api-key': 'YOUR_API_KEY', 'x-api-secret': 'YOUR_API_SECRET' }
});

Direct Ticket Creation

javascript
const response = await axios.post('https://pool.swypt.io/api/offramp-ticket', {
  phone: "254703710518",
  amount: "100",
  description: "Failed withdrawal attempt",
  side: "off-ramp",
  userAddress: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
  symbol: "USDT",
  tokenAddress: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
  chain: "Polygon"
}, {
  headers: { 'x-api-key': 'YOUR_API_KEY', 'x-api-secret': 'YOUR_API_SECRET' }
});

Successful Response

json
{
  "status": "success",
  "data": {
    "refund": {
      "PhoneNumber": "254703710518",
      "Amount": "100",
      "Description": "Failed withdrawal attempt",
      "Side": "off-ramp",
      "userAddress": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
      "symbol": "USDT",
      "tokenAddress": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
      "chain": "Polygon",
      "_id": "507f1f77bcf86cd799439011",
      "createdAt": "2025-02-15T12:00:00.000Z"
    }
  }
}

On-Ramp Flow

The on-ramp process consists of three steps:

  1. Initiate STK Push for M-Pesa payment
  2. Monitor transaction status until SUCCESS
  3. Process crypto transfer to user after confirmed payment

Step 1 — Initiate STK Push

POSThttps://pool.swypt.io/api/onramp-orders
ParameterDescriptionRequiredExample
partyAUser's phone numberYes"254703710518"
amountAmount in KESYes"5000"
sideTransaction sideYes"onramp"
userAddressUser's blockchain addressYes"0x742d35..."
tokenAddressToken contract address or asset IDYes"0xc2132D05..." | "31566704"

Example (EVM)

javascript
const response = await axios.post('https://pool.swypt.io/api/onramp-orders', {
  partyA: "254703710518",
  amount: "5000",
  side: "onramp",
  userAddress: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
  tokenAddress: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
}, {
  headers: { 'x-api-key': 'YOUR_API_KEY', 'x-api-secret': 'YOUR_API_SECRET' }
});

Example (Algorand)

javascript
const response = await axios.post('https://pool.swypt.io/api/onramp-orders', {
  partyA: "254703710518",
  amount: "5000",
  side: "onramp",
  userAddress: "XEI2YQ47YAEDJEOYE3KQTYJNRCA2G2TO7U4STRYMOOXAZMIHRQ7HEEPGOE",
  tokenAddress: "31566704"
}, {
  headers: { 'x-api-key': 'YOUR_API_KEY', 'x-api-secret': 'YOUR_API_SECRET' }
});

Successful Response

json
{
  "status": "success",
  "message": "STK Push initiated successfully",
  "data": {
    "orderID": "D-rclsg-VL",
    "message": "Success. Request accepted for processing"
  }
}

Step 2 — Check Onramp Status

GEThttps://pool.swypt.io/api/onramp-order-status/:orderID
javascript
const response = await axios.get('https://pool.swypt.io/api/onramp-order-status/D-rclsg-VL', {
  headers: { 'x-api-key': 'YOUR_API_KEY', 'x-api-secret': 'YOUR_API_SECRET' }
});

Response — Success:

json
{
  "status": "success",
  "data": {
    "status": "SUCCESS",
    "message": "Deposit completed successfully",
    "orderID": "D-ri3b1-7H",
    "details": {
      "phoneNumber": "254703710518",
      "mpesaReceipt": "TBF842GPCO",
      "transactionDate": "2025-02-15T08:33:38.000Z",
      "resultDescription": "Transaction initiated"
    }
  }
}

Response — Pending:

json
{
  "status": "success",
  "data": {
    "status": "PENDING",
    "message": "Your deposit is being processed",
    "orderID": "D-roug7-UT",
    "details": {
      "phoneNumber": "254703710518",
      "mpesaReceipt": "ws_CO_15022025083848183703710518",
      "transactionDate": "2025-02-15T08:38:48.000Z",
      "resultDescription": "Transaction initiated"
    }
  }
}

Response — Failed:

json
{
  "status": "success",
  "data": {
    "status": "FAILED",
    "message": "Insufficient balance",
    "orderID": "D-rm3qn-3Q",
    "details": {
      "phoneNumber": "254703710518",
      "mpesaReceipt": "ws_CO_15022025083640743703710518",
      "transactionDate": "2025-02-15T08:36:40.000Z",
      "resultDescription": "Insufficient balance"
    }
  }
}

Step 3 — Process Crypto Transfer

POSThttps://pool.swypt.io/api/deposit
Only call this endpoint after a confirmed SUCCESS status on the STK push.
ParameterDescriptionRequiredExample
chainBlockchain networkYes"celo" | "algorand"
addressRecipient addressYes"0x742d35..."
orderIDOriginal transaction order IDYes"D-ri3b1-7H"
projectProject identifierYes"project-mocha"

Example (EVM)

javascript
const response = await axios.post('https://pool.swypt.io/api/deposit', {
  chain: "celo",
  address: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
  orderID: "D-ri3b1-7H",
  project: "project-mocha"
}, {
  headers: { 'x-api-key': 'YOUR_API_KEY', 'x-api-secret': 'YOUR_API_SECRET' }
});

Response:

json
{
  "status": 200,
  "message": "Transaction processed successfully",
  "createdAt": "2025-02-15T08:33:38.000Z",
  "updatedAt": "2025-02-15T08:33:45.000Z",
  "hash": "0x80856f025035da9387873410155c4868c1825101e2c06d580aea48e8179b5e0b",
  "tokenAddress": "0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e",
  "cryptoAmount": 38.46153846153846,
  "chain": "celo",
  "orderID": "D-ri3b1-7H",
  "MpesaReceiptNumber": "TGA6EIIORA"
}

Example (Algorand)

javascript
const response = await axios.post('https://pool.swypt.io/api/deposit', {
  chain: "algorand",
  address: "XEI2YQ47YAEDJEOYE3KQTYJNRCA2G2TO7U4STRYMOOXAZMIHRQ7HEEPGOE",
  orderID: "D-ri3b1-7H",
  project: "project-mocha"
}, {
  headers: { 'x-api-key': 'YOUR_API_KEY', 'x-api-secret': 'YOUR_API_SECRET' }
});

Response:

json
{
  "status": 200,
  "message": "Transaction processed successfully",
  "hash": "YQTZJW7RKT6JARGNE5XVO4GI7GZWNLTEVDGB24RG6ZLG6OG5PO4Q",
  "tokenAddress": "31566704",
  "cryptoAmount": 38.46153846153846,
  "chain": "algorand",
  "orderID": "D-ri3b1-7H",
  "MpesaReceiptNumber": "TGA6EIIORA",
  "algorandTransaction": {
    "explorerUrl": "https://algoexplorer.io/tx/YQTZJW7RKT6JARGNE5XVO4GI7GZWNLTEVDGB24RG6ZLG6OG5PO4Q",
    "formattedAmount": "38.461538 USDC",
    "formattedFee": "0.001000 ALGO",
    "round": 57960848,
    "assetId": 31566704,
    "timestamp": "2025-02-15T08:33:38.000Z"
  }
}

Create Onramp Ticket

POSThttps://pool.swypt.io/api/onramp-ticket

Only failed or cancelled transactions can be used with orderID for onramp tickets.

Either provide orderID OR all other fields. When using orderID, ticket data is populated from the failed transaction.

From Failed Transaction

javascript
const response = await axios.post('https://pool.swypt.io/api/onramp-ticket', {
  orderID: "D-rm3qn-3Q",
  description: "Refund for failed STK push"
}, {
  headers: { 'x-api-key': 'YOUR_API_KEY', 'x-api-secret': 'YOUR_API_SECRET' }
});

Direct Ticket Creation

javascript
const response = await axios.post('https://pool.swypt.io/api/onramp-ticket', {
  phone: "254703710518",
  amount: "5000",
  description: "Failed deposit attempt",
  side: "on-ramp",
  userAddress: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
  symbol: "USDT",
  tokenAddress: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
  chain: "Polygon"
}, {
  headers: { 'x-api-key': 'YOUR_API_KEY', 'x-api-secret': 'YOUR_API_SECRET' }
});

Successful Response

json
{
  "status": "success",
  "data": {
    "refund": {
      "PhoneNumber": "254703710518",
      "Amount": "5000",
      "Description": "Failed deposit attempt",
      "Side": "on-ramp",
      "userAddress": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
      "symbol": "USDT",
      "tokenAddress": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
      "chain": "Polygon",
      "_id": "507f1f77bcf86cd799439011",
      "createdAt": "2025-02-15T12:00:00.000Z"
    }
  }
}

Transaction History

Both endpoints return transactions sorted from latest to oldest with pagination. All timestamps are ISO 8601 (UTC).

Get User Onramp Transactions

GEThttps://pool.swypt.io/api/deposit-transactions/{userAddress}
javascript
const response = await axios.get(
  'https://pool.swypt.io/api/deposit-transactions/0xb4da1bab9089BeE775577B3c6e27133aaf3946aA',
  { headers: { 'x-api-key': 'YOUR_API_KEY', 'x-api-secret': 'YOUR_API_SECRET' } }
);

Response:

json
{
  "status": 200,
  "message": "Transactions retrieved successfully (sorted from latest to oldest)",
  "data": [
    {
      "id": "686fb289c86af65ade30aaf6",
      "MpesaReceiptNumber": "TGA6EIIORA",
      "TransactionDate": "2025-07-10T12:31:05.398Z",
      "cryptoAmount": "0.1621872103799815",
      "feeAmount": "1",
      "side": "onramp",
      "symbol": "USDT",
      "isSent": true,
      "createdAt": "2025-07-10T12:31:05.398Z",
      "Amount": 21,
      "orderID": "D-d9m0k-T8",
      "transactionID": "0x65d0ab0e24679a1b88411a84d4e7b485c8f30b31539841aed09231a0c7508a32",
      "PhoneNumber": 254703710518,
      "resultDescription": "Transaction initiated"
    }
  ],
  "pagination": {
    "currentPage": 1,
    "limit": 10,
    "totalPages": 3,
    "totalCount": 28
  }
}

Onramp Transaction Fields

MpesaReceiptNumberM-Pesa transaction receipt
TransactionDateWhen the transaction occurred
cryptoAmountAmount of crypto received
feeAmountFee charged in fiat currency
sideTransaction type ("onramp")
symbolCryptocurrency symbol
AmountFiat amount deposited
orderIDUnique transaction identifier
transactionIDBlockchain transaction hash
isSentWhether crypto was sent to user

Get User Offramp Transactions

GEThttps://pool.swypt.io/api/withdrawal-transactions/{userAddress}
javascript
const response = await axios.get(
  'https://pool.swypt.io/api/withdrawal-transactions/0xb4da1bab9089BeE775577B3c6e27133aaf3946aA',
  { headers: { 'x-api-key': 'YOUR_API_KEY', 'x-api-secret': 'YOUR_API_SECRET' } }
);

Response:

json
{
  "status": 200,
  "message": "B2C transactions retrieved successfully (sorted from latest to oldest)",
  "data": [
    {
      "id": "686fb209c86af65ade30aabc",
      "TransactionAmount": 38,
      "TransactionReceipt": "TGA2EI5X5C",
      "ReceiverPartyPublicName": "254703710518 - Henry Kariuki Nyagah",
      "TransactionCompletedDateTime": "2025-07-10T12:28:57.273Z",
      "transactionID": "0x52b86f766f41938321b4ba50362c4eb69e0a975e9130deeba2c66e0826053d88",
      "transactionSize": "38",
      "transactionFee": "0.007723",
      "transactionSide": "papasharky",
      "exchangeRate": "129.48",
      "createdAt": "2025-07-10T12:28:57.273Z",
      "chain": "lisk",
      "isSent": true,
      "orderID": "WD-d6v5j-FB",
      "PhoneNumber": "254703710518",
      "resultDescription": "Transaction completed successfully"
    }
  ],
  "pagination": {
    "currentPage": 1,
    "limit": 10,
    "totalPages": 1,
    "totalCount": 10
  }
}

Offramp Transaction Fields

TransactionAmountFiat amount sent to user
TransactionReceiptM-Pesa receipt number
ReceiverPartyPublicNameRecipient name from M-Pesa
transactionIDBlockchain transaction hash
transactionSizeAmount in fiat currency
transactionFeeFee charged in crypto
exchangeRateCrypto-to-fiat exchange rate
chainBlockchain network used
orderIDUnique transaction identifier
isSentWhether fiat was successfully sent

Integration Examples

Complete end-to-end integration examples for common flows.

Algorand Offramp — Full Flow

javascript
import algosdk from 'algosdk';
import axios from 'axios';

const algodClient = new algosdk.Algodv2('', 'https://mainnet-api.algonode.cloud', 443);
const SWYPT_WALLET = 'XEI2YQ47YAEDJEOYE3KQTYJNRCA2G2TO7U4STRYMOOXAZMIHRQ7HEEPGOE';
const USDC_ASSET_ID = 31566704;
const HEADERS = { 'x-api-key': 'YOUR_API_KEY', 'x-api-secret': 'YOUR_API_SECRET' };

// 1. Get quote
const quote = await axios.post('https://pool.swypt.io/api/fx-quotes', {
  type: "offramp",
  fiatAmount: "1000",
  cryptoCurrency: "USDC",
  fiatCurrency: "KES",
  network: "algorand",
  category: "B2C"
}, { headers: HEADERS });

const { inputAmount, fee } = quote.data.data;
const totalUSDC = parseFloat(inputAmount) + parseFloat(fee.amount);

// 2. Send USDC to Swypt
const suggestedParams = await algodClient.getTransactionParams().do();
const amountInBaseUnits = Math.floor(totalUSDC * 1_000_000);

const txn = algosdk.makeAssetTransferTxnWithSuggestedParamsFromObject({
  sender: userAddress,
  receiver: SWYPT_WALLET,
  amount: amountInBaseUnits,
  assetIndex: USDC_ASSET_ID,
  suggestedParams,
  note: new Uint8Array(Buffer.from('Swypt Offramp'))
});

const signedTxn = await wallet.signTransaction(txn);
const { txId } = await algodClient.sendRawTransaction(signedTxn).do();
await algosdk.waitForConfirmation(algodClient, txId, 4);

// 3. Initiate offramp
const offrampResponse = await axios.post('https://pool.swypt.io/api/offramp-orders', {
  chain: "algorand",
  hash: txId,
  partyB: "254703710518",
  tokenAddress: "31566704",
  project: "your-project",
  userAddress: userAddress
}, { headers: HEADERS });

console.log('Offramp initiated:', offrampResponse.data.data.orderID);

Algorand Onramp — Full Flow

javascript
const HEADERS = { 'x-api-key': 'YOUR_API_KEY', 'x-api-secret': 'YOUR_API_SECRET' };

// 1. Initiate STK Push
const stkResponse = await axios.post('https://pool.swypt.io/api/onramp-orders', {
  partyA: "254703710518",
  amount: "5000",
  side: "onramp",
  userAddress: "XEI2YQ47YAEDJEOYE3KQTYJNRCA2G2TO7U4STRYMOOXAZMIHRQ7HEEPGOE",
  tokenAddress: "31566704"
}, { headers: HEADERS });

const orderID = stkResponse.data.data.orderID;

// 2. Poll for payment confirmation
const checkStatus = async () => {
  const res = await axios.get(
    `https://pool.swypt.io/api/onramp-order-status/${orderID}`,
    { headers: HEADERS }
  );
  return res.data.data.status;
};

let status = 'PENDING';
while (status === 'PENDING') {
  await new Promise(resolve => setTimeout(resolve, 5000)); // wait 5s
  status = await checkStatus();
}

if (status !== 'SUCCESS') {
  throw new Error('Payment failed');
}

// 3. Process crypto transfer
const depositResponse = await axios.post('https://pool.swypt.io/api/deposit', {
  chain: "algorand",
  address: "XEI2YQ47YAEDJEOYE3KQTYJNRCA2G2TO7U4STRYMOOXAZMIHRQ7HEEPGOE",
  orderID: orderID,
  project: "your-project"
}, { headers: HEADERS });

console.log('Deposit tx:', depositResponse.data.hash);