Skip to main content

Create

There are two types of wallets in the system: account wallets and client wallets.

An account wallet is a wallet that accepts funds from client wallets. Roughly speaking, this is the wallet of the business owner. You can create new account wallets or import an existing wallet. A default account wallet and a secondary account wallet are available. Funds are sent to the default account wallet after the client wallet is replenished. All transactions for account wallets are performed on-chain.

Here's a visual representation of how transaction works for crypto account wallets replenishment:

A client wallet is a wallet that is created when a customer pays for a product or service. A business owner can create a client wallet himself and reset it to a client for replenishment. Also, such wallets are generated when paying for a checkout: donation, sale, sale token or cart. The balance on the client wallets is virtual, that is, after replenishing such a wallet, funds are sent to the account wallet. However, the client wallet also displays the balance for the amount by which it was replenished.

Here's a visual representation of how transaction works for crypto clients wallets replenishment:

Withdrawal of funds for account wallets occurs as follows:

For client wallets, the withdrawal is made according to the same principle, the withdrawal is made from the default wallet of the account, but the client wallet is substituted in the withdrawal transaction. After the withdrawal, the balance of the client wallet and the default wallet of the account is updated.

Work with client wallets is performed via API. To get started, you need to get the account API keys:

Next you need to get the account's JWT token:

post
Endpoint POST /api/public/auth
Endpoint allows you to log in to the system under the account. publicKey and privateKey can be obtained from the account. There is a corresponding endpoint that generates these keys for the account.

Parameters

Body

  • publicKey

    *

    string

  • privateKey

    *

    string

Responses

  • 200:OK
    {
    token: "String"
    }
  • 200:OK

    Example

    {
    token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYxOTIzNjAyNjM3OTE4MDFkMGQzODgzNiIsInVzZXIiOiI2MDlhNjM0MGU1ZTFjZjAyMTU2ZDBkZjciLCJpYXQiOjE2NjQyMjk2NzAsImV4cCI6MTY2NDMxNjA3MH0.9pMjfySEl-3AK6wSrH6I7_2wawnwMohyTKVTqd5ELew"
    }
  • 400:Bad request

    If request body parameters are empty or have incorrect type (not string)

    {
    status: "fail",
    data: {
    message: [
    "publicKey should not be empty",
    "privateKey should not be empty"
    ]
    }
    }
  • 401

    If you use incorrect account token

    {
    status: "fail",
    data: {
    message: "Unauthorized"
    }
    }

After that you can create a wallet (both client and account):

post
Endpoint POST ​/api​/public​/wallet​/{currencyId}
You need to log in to the account.

Parameters

Path

  • currencyId

    *

    string

Body

  • typeWallet

    *

    string

    merchant, user

  • privateKey

    string

  • isMnemonic

    boolean

    if true then fill mnemonic phrase to privateKey parameter

  • setMain

    boolean

  • password

    string

Responses

  • 200:OK
    {
    data: {
    id: "string",
    address: "string",
    balance: 0,
    balanceUSD: 0,
    passphrase: "string"
    }
    }
  • 200:OK

    Example

    {
    data: {
    id: "63321da650a1280200bcacca",
    address: "0x3Cf221e9AFdCc4792c5fF7631CB84b6e8a066c7a",
    balance: "0",
    balanceUSD: "0",
    passphrase: "d1295f73-1cfc-4bde-bcca-c496944b9dd5"
    }
    }
  • 400:Bad request
    {
    message: "This currency is not supported."
    }
  • 401
    {
    status: "fail",
    data: {
    message: "Unauthorized"
    }
    }

Next you can replenish the wallet you created. If you need to make a withdrawal, use this request, but first you need to get JWT token for wallet:

post
Endpoint POST /api/public/auth

Parameters

Request body

  • publicKey

    *

    string

  • privateKey

    *

    string

  • walletId

    *

    string

  • passphrase

    *

    string

Responses

  • 200:OK
    {
    token: "String"
    }
  • 200:Example
    {
    token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyMDI5MDg0ZDA4NmM2MDExMzc3ODFlMiIsInVzZXIiOiI2MDlhNjM0MGU1ZTFjZjAyMTU2ZDBkZjciLCJpYXQiOjE2OTgyNDU5NTcsImV4cCI6MTY5ODMzMjM1N30.ogoBh6UolGWJUy0bOcNPjNNqPqstoj8ld_u3siUSEQU"
    }
post
Endpoint POST ​/api​/public​/withdrawal

Parameters

Headers

  • Idempotency-Key

    string

    This means that if the same request is sent multiple times with the same unique Idempotency-Key header, it won’t create duplicate transactions. This is especially useful in cases where a connection drops or a request is retried — only one transaction will be executed.

Body

  • to

    *

    string

  • amount

    *

    number

  • currencyToken

    string

    Used if withdrawals are made from the account’s wallet

  • comment

    string

    Use for TON and USDT TON

  • password

    string

  • sign

    string

    base64 format

Responses

  • 200:OK
    {
    data: {
    id: "string"
    }
    }
  • 200:OK

    Example

    {
    data: {
    id: "63321f4d50a1280200bcaccd"
    }
    }
  • 400:Bad request
    {
    status: "fail",
    data: {
    message: "Address INVALID"
    }
    }
  • 401
    {
    status: "fail",
    data: {
    message: "Unauthorized"
    }
    }

Client wallets also have the ability to perform off-chain transactions within CPAY, which is very useful if you want to move funds between your users in your system:

post
Endpoint POST /api​/public​/withdrawal​/internal
Internal Transfer is the ability to transfer funds between client wallets using the API, within one account, without creating a transaction on the blockchain.

Parameters

Headers

  • Idempotency-Key

    string

    This means that if the same request is sent multiple times with the same unique Idempotency-Key header, it won’t create duplicate transactions. This is especially useful in cases where a connection drops or a request is retried — only one transaction will be executed.

Body

  • to

    *

    string

  • amount

    *

    number

Responses

  • 200:OK
    {
    "data": {
    "id": "String"
    }
    }
  • 200:OK

    Example

    {
    "data": {
    "id": "634ecbb9053b310076f5c309"
    }
    }
  • 400:Bad request
    {
    "status": "fail",
    "data": {
    "message": "Wallet not found in this account."
    }
    }

To process transactions of your wallets in your system, use callbacks - https://docs.cpay.world/for-developers/callbacks

More detailed information on working with the API for wallets is available on the page - https://docs.cpay.world/for-developers/api/using-api-for-wallet

Each wallet in the system is unique, you cannot create two identical wallets.

Next comes the presentation of the work on creating wallets through the interface.

To create an account wallet, you need to go to the Account Wallet page, click on the Create new wallet button, select the New option, select the currency you need and click on the Create button:

Set as default - allows you to set the secondary wallet as default. There is a default wallet for every currency. The default ones are located at the top of the list. Funds are sent to them from client wallets. Client wallets are all installed by default.

Set password - password for auto-signing.

To create a client wallet, you need to go to the Client Wallet page, click on the Create new wallet button, select the New option, select the currency you need and click on the Create button:

You can create several wallets at once:

Copy link