Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 

Repository files navigation

SWYPT API DOCUMENTATION FOR ON-RAMPS & OFF-RAMPS

This repo serves as documentation for integration with Swypt APIs and smart contract functions.


Deployed Contracts

EVM Chains

Algorand


SWYPT SMART CONTRACT ABI

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

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

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',
  },
  {
    inputs: [{ internalType: 'address', name: 'target', type: 'address' }],
    name: 'AddressEmptyCode',
    type: 'error',
  },
  {
    inputs: [{ internalType: 'uint256', name: 'err', type: 'uint256' }],
    name: 'AddressZero',
    type: 'error',
  },
  {
    inputs: [{ internalType: 'address', name: 'implementation', type: 'address' }],
    name: 'ERC1967InvalidImplementation',
    type: 'error',
  },
  { inputs: [], name: 'ERC1967NonPayable', type: 'error' },
  { inputs: [], name: 'EnforcedPause', type: 'error' },
  { inputs: [], name: 'ExpectedPause', type: 'error' },
  { inputs: [], name: 'FailedCall', type: 'error' },
  {
    inputs: [{ internalType: 'uint256', name: 'err', type: 'uint256' }],
    name: 'InsufficientBalance',
    type: 'error',
  },
  { inputs: [], name: 'InvalidInitialization', type: 'error' },
  { inputs: [], name: 'NotInitializing', type: 'error' },
  {
    inputs: [{ internalType: 'address', name: 'owner', type: 'address' }],
    name: 'OwnableInvalidOwner',
    type: 'error',
  },
  {
    inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
    name: 'OwnableUnauthorizedAccount',
    type: 'error',
  },
  { inputs: [], name: 'ReentrancyGuardReentrantCall', type: 'error' },
  {
    inputs: [{ internalType: 'uint256', name: 'err', type: 'uint256' }],
    name: 'TransferFailed',
    type: 'error',
  },
  { inputs: [], name: 'UUPSUnauthorizedCallContext', type: 'error' },
  {
    inputs: [{ internalType: 'bytes32', name: 'slot', type: 'bytes32' }],
    name: 'UUPSUnsupportedProxiableUUID',
    type: 'error',
  },
  {
    anonymous: false,
    inputs: [{ indexed: false, internalType: 'address', name: 'newBeneficiary', type: 'address' }],
    name: 'BeneficiaryUpdated',
    type: 'event',
  },
  {
    anonymous: false,
    inputs: [
      { indexed: false, internalType: 'address', name: 'user', type: 'address' },
      { indexed: false, internalType: 'address', name: 'token', type: 'address' },
      { indexed: true, internalType: 'uint256', name: 'amount', type: 'uint256' },
      { indexed: true, internalType: 'uint256', name: 'nonce', type: 'uint256' },
    ],
    name: 'Deposited',
    type: 'event',
  },
  {
    anonymous: false,
    inputs: [
      { indexed: true, internalType: 'address', name: 'tokenAddress', type: 'address' },
      { indexed: true, internalType: 'address', name: 'beneficiary', type: 'address' },
      { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
    ],
    name: 'FundsWithdrawn',
    type: 'event',
  },
  {
    anonymous: false,
    inputs: [{ indexed: false, internalType: 'uint64', name: 'version', type: 'uint64' }],
    name: 'Initialized',
    type: 'event',
  },
  {
    anonymous: false,
    inputs: [
      { indexed: true, internalType: 'address', name: 'user', type: 'address' },
      { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
    ],
    name: 'NativeTokenDeposited',
    type: 'event',
  },
  {
    anonymous: false,
    inputs: [
      { indexed: true, internalType: 'address', name: 'previousOwner', type: 'address' },
      { indexed: true, internalType: 'address', name: 'newOwner', type: 'address' },
    ],
    name: 'OwnershipTransferred',
    type: 'event',
  },
  {
    anonymous: false,
    inputs: [{ indexed: false, internalType: 'address', name: 'account', type: 'address' }],
    name: 'Paused',
    type: 'event',
  },
  {
    anonymous: false,
    inputs: [
      { indexed: true, internalType: 'address', name: 'user', type: 'address' },
      { indexed: true, internalType: 'address', name: 'token', type: 'address' },
      { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
    ],
    name: 'Refunded',
    type: 'event',
  },
  {
    anonymous: false,
    inputs: [
      { indexed: true, internalType: 'bytes32', name: 'role', type: 'bytes32' },
      { indexed: true, internalType: 'bytes32', name: 'previousAdminRole', type: 'bytes32' },
      { indexed: true, internalType: 'bytes32', name: 'newAdminRole', type: 'bytes32' },
    ],
    name: 'RoleAdminChanged',
    type: 'event',
  },
  {
    anonymous: false,
    inputs: [
      { indexed: true, internalType: 'bytes32', name: 'role', type: 'bytes32' },
      { indexed: true, internalType: 'address', name: 'account', type: 'address' },
      { indexed: true, internalType: 'address', name: 'sender', type: 'address' },
    ],
    name: 'RoleGranted',
    type: 'event',
  },
  {
    anonymous: false,
    inputs: [
      { indexed: true, internalType: 'bytes32', name: 'role', type: 'bytes32' },
      { indexed: true, internalType: 'address', name: 'account', type: 'address' },
      { indexed: true, internalType: 'address', name: 'sender', type: 'address' },
    ],
    name: 'RoleRevoked',
    type: 'event',
  },
  {
    anonymous: false,
    inputs: [{ indexed: false, internalType: 'address', name: 'account', type: 'address' }],
    name: 'Unpaused',
    type: 'event',
  },
  {
    anonymous: false,
    inputs: [{ indexed: true, internalType: 'address', name: 'implementation', type: 'address' }],
    name: 'Upgraded',
    type: 'event',
  },
  {
    anonymous: false,
    inputs: [{ indexed: false, internalType: 'uint256', name: 'newMerchantCode', type: 'uint256' }],
    name: 'WhitelistRemoved',
    type: 'event',
  },
  {
    anonymous: false,
    inputs: [{ indexed: false, internalType: 'uint256', name: 'merchantCode', type: 'uint256' }],
    name: 'WhitelistSet',
    type: 'event',
  },
  {
    anonymous: false,
    inputs: [
      { indexed: false, internalType: 'address', name: 'user', type: 'address' },
      { indexed: false, internalType: 'address', name: 'token', type: 'address' },
      { indexed: true, internalType: 'uint256', name: 'amount', type: 'uint256' },
      { indexed: true, internalType: 'uint256', name: 'time', type: 'uint256' },
    ],
    name: 'sentToUser',
    type: 'event',
  },
  {
    inputs: [],
    name: 'DEFAULT_ADMIN_ROLE',
    outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }],
    stateMutability: 'view',
    type: 'function',
  },
  {
    inputs: [],
    name: 'UPGRADE_INTERFACE_VERSION',
    outputs: [{ internalType: 'string', name: '', type: 'string' }],
    stateMutability: 'view',
    type: 'function',
  },
  {
    inputs: [],
    name: 'beneficiary',
    outputs: [{ internalType: 'address', name: '', type: 'address' }],
    stateMutability: 'view',
    type: 'function',
  },
  {
    inputs: [],
    name: 'depositNonce',
    outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
    stateMutability: 'view',
    type: 'function',
  },
  {
    inputs: [
      { internalType: 'address', name: '_userAddress', type: 'address' },
      { internalType: 'address', name: '_token', type: 'address' },
      { internalType: 'uint256', name: '_amount', type: 'uint256' },
    ],
    name: 'depositToWallet',
    outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
    stateMutability: 'nonpayable',
    type: 'function',
  },
  {
    inputs: [{ internalType: 'uint256', name: '_refCode', type: 'uint256' }],
    name: 'getReferralInfo',
    outputs: [
      {
        components: [
          { internalType: 'uint256', name: '_merchantCode', type: 'uint256' },
          { internalType: 'uint256', name: '_feeSplit', type: 'uint256' },
        ],
        internalType: 'struct IPool.ReferralInfoV2[]',
        name: '',
        type: 'tuple[]',
      },
    ],
    stateMutability: 'view',
    type: 'function',
  },
  {
    inputs: [{ internalType: 'bytes32', name: 'role', type: 'bytes32' }],
    name: 'getRoleAdmin',
    outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }],
    stateMutability: 'view',
    type: 'function',
  },
  {
    inputs: [{ internalType: 'uint256', name: '_newMerchantCode', type: 'uint256' }],
    name: 'getSplitFeeInfo',
    outputs: [
      {
        components: [
          { internalType: 'uint256', name: '_refCode', type: 'uint256' },
          { internalType: 'uint256', name: '_feeSplit', type: 'uint256' },
        ],
        internalType: 'struct IPool.ReferralInfoV1',
        name: '',
        type: 'tuple',
      },
    ],
    stateMutability: 'view',
    type: 'function',
  },
  {
    inputs: [
      { internalType: 'bytes32', name: 'role', type: 'bytes32' },
      { internalType: 'address', name: 'account', type: 'address' },
    ],
    name: 'grantRole',
    outputs: [],
    stateMutability: 'nonpayable',
    type: 'function',
  },
  {
    inputs: [
      { internalType: 'bytes32', name: 'role', type: 'bytes32' },
      { internalType: 'address', name: 'account', type: 'address' },
    ],
    name: 'hasRole',
    outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
    stateMutability: 'view',
    type: 'function',
  },
  {
    inputs: [
      { internalType: 'address', name: '_defaultAdmin', type: 'address' },
      { internalType: 'address', name: '_beneficiary', type: 'address' },
    ],
    name: 'initialize',
    outputs: [],
    stateMutability: 'nonpayable',
    type: 'function',
  },
  {
    inputs: [{ internalType: 'address', name: '', type: 'address' }],
    name: 'isWhitelistedAddress',
    outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
    stateMutability: 'view',
    type: 'function',
  },
  {
    inputs: [{ internalType: 'address', name: '', type: 'address' }],
    name: 'isWhitelistedAsset',
    outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
    stateMutability: 'view',
    type: 'function',
  },
  {
    inputs: [],
    name: 'owner',
    outputs: [{ internalType: 'address', name: '', type: 'address' }],
    stateMutability: 'view',
    type: 'function',
  },
  {
    inputs: [],
    name: 'pause',
    outputs: [],
    stateMutability: 'nonpayable',
    type: 'function',
  },
  {
    inputs: [],
    name: 'paused',
    outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
    stateMutability: 'view',
    type: 'function',
  },
  {
    inputs: [],
    name: 'proxiableUUID',
    outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }],
    stateMutability: 'view',
    type: 'function',
  },
  {
    inputs: [
      { internalType: 'address', name: '_userAddress', type: 'address' },
      { internalType: 'address', name: '_tokenAddress', type: 'address' },
      { internalType: 'uint256', name: '_amount', type: 'uint256' },
    ],
    name: 'refundUser',
    outputs: [],
    stateMutability: 'nonpayable',
    type: 'function',
  },
  {
    inputs: [
      { internalType: 'uint256', name: '_merchantCode', type: 'uint256' },
      { internalType: 'uint256', name: '_refCode', type: 'uint256' },
    ],
    name: 'removeWhitelistedAddress',
    outputs: [{ internalType: 'bool', name: 'success', type: 'bool' }],
    stateMutability: 'nonpayable',
    type: 'function',
  },
  {
    inputs: [],
    name: 'renounceOwnership',
    outputs: [],
    stateMutability: 'nonpayable',
    type: 'function',
  },
  {
    inputs: [
      { internalType: 'bytes32', name: 'role', type: 'bytes32' },
      { internalType: 'address', name: 'callerConfirmation', type: 'address' },
    ],
    name: 'renounceRole',
    outputs: [],
    stateMutability: 'nonpayable',
    type: 'function',
  },
  {
    inputs: [
      { internalType: 'bytes32', name: 'role', type: 'bytes32' },
      { internalType: 'address', name: 'account', type: 'address' },
    ],
    name: 'revokeRole',
    outputs: [],
    stateMutability: 'nonpayable',
    type: 'function',
  },
  {
    inputs: [{ internalType: 'address', name: '_newBeneficiary', type: 'address' }],
    name: 'setBeneficiary',
    outputs: [],
    stateMutability: 'nonpayable',
    type: 'function',
  },
  {
    inputs: [{ internalType: 'bytes4', name: 'interfaceId', type: 'bytes4' }],
    name: 'supportsInterface',
    outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
    stateMutability: 'view',
    type: 'function',
  },
  {
    inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }],
    name: 'transferOwnership',
    outputs: [],
    stateMutability: 'nonpayable',
    type: 'function',
  },
  {
    inputs: [],
    name: 'unpause',
    outputs: [],
    stateMutability: 'nonpayable',
    type: 'function',
  },
  {
    inputs: [
      { internalType: 'address', name: 'newImplementation', type: 'address' },
      { internalType: 'bytes', name: 'data', type: 'bytes' },
    ],
    name: 'upgradeToAndCall',
    outputs: [],
    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',
  },
  {
    inputs: [
      { internalType: 'uint256', name: '_merchantCode', type: 'uint256' },
      { internalType: 'uint256', name: '_refCode', type: 'uint256' },
      { internalType: 'uint256', name: '_feeToSplit', type: 'uint256' },
    ],
    name: 'whitelistAddress',
    outputs: [{ internalType: 'bool', name: 'success', type: 'bool' }],
    stateMutability: 'nonpayable',
    type: 'function',
  },
  {
    inputs: [
      { internalType: 'address', name: '_tokenAddress', type: 'address' },
      { internalType: 'uint256', name: '_amount', type: 'uint256' },
      { internalType: 'address', name: '_userAddress', type: 'address' },
    ],
    name: 'withdrawFunds',
    outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
    stateMutability: 'nonpayable',
    type: 'function',
  },
  {
    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',
  },
  { stateMutability: 'payable', type: 'receive' },
];

Key Functions for Integration

The main functions used for offramp operations on EVM chains are:

  1. withdrawToEscrow — Standard withdrawal (requires prior token approval)
  2. viewDepositWithNonce — View withdrawal details by nonce

Getting Quotes

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

Get Quote Endpoint

POST https://pool.swypt.io/api/fx-quotes

Authentication Required

Include the following headers:

  • x-api-key: Your API key
  • x-api-secret: Your API secret

Request Parameters

Parameter Description Example Required
type Type of operation (onramp or offramp) "onramp" Yes
amount or fiatAmount Amount to convert "5000" Yes
fiatCurrency Fiat currency code "KES" Yes
cryptoCurrency Cryptocurrency symbol "USDT" Yes
network Blockchain network "celo" Yes
category Transaction category (offramp only) "B2C" No

Example — Onramp (KES → USDT)

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'
  }
});

Example — Offramp (USDT → KES)

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'
  }
});

Example — Algorand Offramp (USDC → KES)

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'
  }
});

Successful Response — Offramp Quote

{
  "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"
    }
  }
}

Successful Response — Onramp Quote

{
  "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"
    }
  }
}

Error Responses

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

Get Supported Assets

GET https://pool.swypt.io/api/listed-assets

Authentication Required

  • x-api-key: Your API key
  • x-api-secret: Your API secret

Example Request

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 Format

{
  "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.

Parameters

  • _tokenAddress (address): Token contract address
  • _amountPlusfee (uint256): Total withdrawal amount including fees
  • _feeAmount (uint256): Fee amount in crypto (from fee.amount in the fx-quote response)

Returns

  • nonce (uint256): Unique identifier for the withdrawal transaction
// 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

  1. User must be opted into USDC (Asset ID: 31566704)
  2. User must have sufficient ALGO for transaction fees (~0.001 ALGO)
  3. User must have sufficient USDC balance
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

POST https://pool.swypt.io/api/offramp-orders

Authentication Required

  • x-api-key: Your API key
  • x-api-secret: Your API secret

Request Parameters

Parameter Description Required Example (EVM) Example (Algorand)
chain Blockchain network Yes "celo" "algorand"
hash Transaction hash Yes "0x80856f..." (66 chars) "YQTZJW7RKT..." (52 chars)
partyB Recipient phone number Yes "254703710518" "254703710518"
tokenAddress Token address or asset ID Yes "0x48065fbBE..." "31566704"
project Your project name Yes "project-mocha" "project-mocha"
userAddress User's wallet address Yes "0x98e35888..." (42 chars) "XEI2YQ47..." (58 chars)

NOTE: The project field is required to help identify and process pending/failed transactions.

Example Request (EVM)

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 Request (Algorand)

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 (EVM)

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

Successful Response (Algorand)

{
  "status": "success",
  "message": "Withdrawal payment initiated successfully",
  "data": {
    "orderID": "WD-xsy6e-HO",
    "algorandTransaction": {
      "explorerUrl": "https://algoexplorer.io/tx/YQTZJW7RKT6JARGNE5XVO4GI7GZWNLTEVDGB24RG6ZLG6OG5PO4Q",
      "round": 57960848,
      "confirmations": 5,
      "assetId": 31566704
    }
  }
}

Error Responses

{ "status": "error", "message": "This blockchain transaction has already been processed", "data": { "orderID": "WD-xsy6e-HO" } }
{ "status": "error", "message": "Missing required parameters: tokenAddress, hash, or phone number" }
{ "status": "error", "message": "Unsupported blockchain: [chain name]" }

Check Offramp Transaction Status

GET https://pool.swypt.io/api/offramp-order-status/:orderID

Authentication Required

  • x-api-key: Your API key
  • x-api-secret: Your API secret

URL Parameters

Parameter Location Description Required Example
orderID URL Transaction order ID Yes "WD-xsy6e-HO"

Example Request

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

  • PENDING — Transaction is being processed
  • SUCCESS — Transaction completed successfully
  • FAILED — Transaction failed

Response — Success

{
  "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

{
  "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

{
  "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"
    }
  }
}

Error Responses

{ "status": "error", "message": "orderID ID is required" }
{ "status": "error", "message": "Transaction with the following WD-xsy6e-HO not found" }
{ "status": "error", "message": "Failed to check withdrawal status" }

Create Offramp Ticket

POST https://pool.swypt.io/api/offramp-ticket

Create a support ticket for failed or pending offramp transactions.

Authentication Required

  • x-api-key: Your API key
  • x-api-secret: Your API secret

Request Parameters

Parameter Description Required Example
orderID ID of failed/pending transaction No* "WD-xsy6e-HO"
phone User's phone number Yes** "254703710518"
amount Crypto amount Yes** "100"
description Ticket description Yes** "Failed withdrawal attempt"
side Transaction side Yes** "off-ramp"
userAddress User's blockchain address Yes** "0x742d35..."
symbol Token symbol Yes** "USDT"
tokenAddress Token contract address or asset ID Yes** "0xc2132D05..." or "31566704"
chain Blockchain network Yes** "Polygon" or "algorand"

* Either orderID OR all other fields are required
** Required only when orderID is not provided

Example — From Failed Transaction

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' }
});

Example — Direct Ticket Creation

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

{
  "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"
    }
  }
}

Important Notes

  • Either provide orderID OR all other required fields
  • When using orderID, ticket data is populated from the failed/pending transaction
  • You can override specific fields (e.g. symbol, chain) even when using orderID
  • Both failed and pending transactions can be used with orderID
  • Phone numbers must be in international format (e.g. "254703710518")

ONRAMP PROCESS FLOW

Step 1 — Initiate STK Push

POST https://pool.swypt.io/api/onramp-orders

Authentication Required

  • x-api-key: Your API key
  • x-api-secret: Your API secret

Request Parameters

Parameter Description Required Example (EVM) Example (Algorand)
partyA User's phone number Yes "254703710518" "254703710518"
amount Amount in KES Yes "5000" "5000"
side Transaction side Yes "onramp" "onramp"
userAddress User's blockchain address Yes "0x742d35..." "XEI2YQ47..."
tokenAddress Token contract address or asset ID Yes "0xc2132D05..." "31566704"

Example Request (EVM)

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 Request (Algorand)

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

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

Error Responses

{ "status": "error", "message": "Failed to record the onramp transaction order" }
{ "status": "error", "message": "Failed to initiate STK Push payment" }
{ "status": "error", "message": "An error occurred during the STK Push transaction" }

Step 2 — Check Onramp Status

GET https://pool.swypt.io/api/onramp-order-status/:orderID

Authentication Required

  • x-api-key: Your API key
  • x-api-secret: Your API secret

URL Parameters

Parameter Description Required Example
orderID Transaction order ID Yes "D-rclsg-VL"

Example Request

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

{
  "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 — Failed

{
  "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"
    }
  }
}

Response — Pending

{
  "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"
    }
  }
}

Error Responses

{ "status": "error", "message": "orderID is required" }
{ "status": "error", "message": "Transaction D-rclsg-VL not found" }
{ "status": "error", "message": "Failed to check deposit status" }

Step 3 — Process Crypto Transfer to User

POST https://pool.swypt.io/api/deposit

NOTE: Only call this endpoint after a confirmed SUCCESS status on the STK push.

Authentication Required

  • x-api-key: Your API key
  • x-api-secret: Your API secret

Request Parameters

Parameter Description Required Example (EVM) Example (Algorand)
chain Blockchain network Yes "celo" "algorand"
address Recipient address Yes "0x742d35..." "XEI2YQ47..."
orderID Original transaction order ID Yes "D-ri3b1-7H" "D-ri3b1-7H"
project Project identifier Yes "project-mocha" "project-mocha"

Example Request (EVM)

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' }
});

Example Request (Algorand)

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' }
});

Successful Response (EVM)

{
  "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"
}

Successful Response (Algorand)

{
  "status": 200,
  "message": "Transaction processed successfully",
  "createdAt": "2025-02-15T08:33:38.000Z",
  "updatedAt": "2025-02-15T08:33:45.000Z",
  "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"
  }
}

Error Responses

{ "status": "error", "message": "Missing required parameters: address or orderID" }
{ "status": "error", "message": "No transaction found for orderID: D-ri3b1-7H" }
{ "status": "error", "message": "Transaction D-ri3b1-7H: STK push payment is being processed" }
{ "status": "error", "message": "Transaction D-ri3b1-7H: Payment failed" }
{ "status": "error", "message": "Transaction D-ri3b1-7H has already been processed" }
{ "status": "error", "message": "Invalid chain: XYZ" }
{ "status": "error", "message": "XYZ chain is not supported" }
{ "status": "error", "message": "Failed to process [Chain] transaction: [specific error message]" }

Create Onramp Ticket

POST https://pool.swypt.io/api/onramp-ticket

Authentication Required

  • x-api-key: Your API key
  • x-api-secret: Your API secret

Request Parameters

Parameter Description Required* Example
orderID ID of failed/cancelled transaction No** "D-rm3qn-3Q"
phone User's phone number Yes "254703710518"
amount Transaction amount Yes "5000"
description Ticket description Yes "Failed STK push attempt"
side Transaction side Yes "on-ramp"
userAddress User's blockchain address Yes "0x742d35..."
symbol Token symbol Yes "USDT"
tokenAddress Token contract address or asset ID Yes "0xc2132D05..." or "31566704"
chain Blockchain network Yes "Polygon" or "algorand"

* Required for direct ticket creation
** If orderID is provided, other fields become optional and are populated from the failed transaction

Example — From Failed Transaction

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' }
});

Example — Direct Ticket Creation

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

{
  "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"
    }
  }
}

Error Responses

{ "status": "error", "message": "Please provide all required inputs: phone, amount, description, side, userAddress, symbol, tokenAddress, and chain" }
{ "status": "error", "message": "No failed transaction found with this orderID" }
{ "status": "error", "message": "ValidationError: [specific validation message]" }
{ "status": "error", "message": "Unable to process refund ticket" }

Important Notes

  • Only failed or cancelled transactions can be used with orderID for onramp tickets
  • Phone numbers must be in international format (e.g. "254703710518")

User Transaction History

Get User Onramp Transactions

GET https://pool.swypt.io/api/deposit-transactions/{userAddress}

Authentication Required

  • x-api-key: Your API key
  • x-api-secret: Your API secret

URL Parameters

Parameter Description Required Example
userAddress User's blockchain address Yes "0xb4da1bab9089BeE775577B3c6e27133aaf3946aA"

Example Request

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' }
});

Successful Response

{
  "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
  }
}

Error Response

{ "status": "error", "message": "No transactions found for the given user address" }

Get User Offramp Transactions

GET https://pool.swypt.io/api/withdrawal-transactions/{userAddress}

Authentication Required

  • x-api-key: Your API key
  • x-api-secret: Your API secret

URL Parameters

Parameter Description Required Example
userAddress User's blockchain address Yes "0xb4da1bab9089BeE775577B3c6e27133aaf3946aA"

Example Request

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' }
});

Successful Response

{
  "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
  }
}

Error Response

{ "status": "error", "message": "No B2C transactions found for the given user address." }

Response Field Reference

Onramp Transaction Fields

  • MpesaReceiptNumber — M-Pesa transaction receipt
  • TransactionDate — When the transaction occurred
  • cryptoAmount — Amount of crypto received
  • feeAmount — Fee charged in fiat currency
  • side — Transaction type ("onramp")
  • symbol — Cryptocurrency symbol (USDT, USDC, etc.)
  • Amount — Fiat amount deposited
  • orderID — Unique transaction identifier
  • transactionID — Blockchain transaction hash
  • PhoneNumber — User's phone number
  • isSent — Whether crypto was successfully sent to user

Offramp Transaction Fields

  • TransactionAmount — Fiat amount sent to user
  • TransactionReceipt — M-Pesa receipt number
  • ReceiverPartyPublicName — Recipient name from M-Pesa
  • TransactionCompletedDateTime — When transaction completed
  • transactionID — Blockchain transaction hash
  • transactionSize — Amount in fiat currency
  • transactionFee — Fee charged in crypto
  • exchangeRate — Crypto-to-fiat exchange rate used
  • chain — Blockchain network used
  • orderID — Unique transaction identifier
  • PhoneNumber — Recipient's phone number
  • isSent — Whether fiat was successfully sent

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


Complete Integration Examples

Algorand Offramp — Full Flow

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

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 = await checkStatus();
while (status === 'PENDING') {
  await new Promise(resolve => setTimeout(resolve, 3000));
  status = await checkStatus();
}

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

  console.log('USDC sent to user:', depositResponse.data.hash);
}

Chain Reference

Supported Chains

Chain Type Token(s)
Celo EVM USDT, USDC, cKES, CELO
Polygon EVM USDT, USDC, MATIC
Base EVM USDC, ETH
Lisk EVM USDT, ETH
Scroll EVM USDT, ETH
Algorand Non-EVM USDC (Asset ID: 31566704)

Address & Hash Format Reference

Chain Address Format Hash Format
EVM (all) 42 chars (0x + 40 hex) 66 chars (0x + 64 hex)
Algorand 58 chars (base32) 52 chars (base32)

Explorer Links

  • Algorand: https://algoexplorer.io/tx/{txHash}
  • Algorand (Pera): https://explorer.perawallet.app/tx/{txHash}
  • Celo: https://celoscan.io/tx/{txHash}
  • Polygon: https://polygonscan.com/tx/{txHash}
  • Base: https://basescan.org/tx/{txHash}
  • Lisk: https://blockscout.lisk.com/tx/{txHash}
  • Scroll: https://scrollscan.com/tx/{txHash}

Algorand-Specific Troubleshooting

Error Cause Solution
"Receiver address is not opted into USDC" User hasn't opted into USDC User must opt into Asset ID 31566704 (costs 0.1 ALGO minimum balance increase)
"Transaction requires 3 confirmations" Not enough confirmations yet Wait ~10 seconds after submission
"Invalid Algorand address format" Wrong address format Address must be exactly 58 base32 characters
"Transaction not found on Algorand blockchain" Propagation delay or wrong hash Wait a moment and verify you're on mainnet
"Insufficient ALGO for transaction fee" Not enough ALGO for fees User needs at least 0.001 ALGO for gas

About

This repo serves as a documentation for integration with swypt APIs and how to integrate with our smart contract functions . Contact support for early access : swypt.io@gmail.com

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors