Exchange Integration Guide - PascalCoin/PascalCoin GitHub Wiki
Simplified Exchange Integration Guide
This document explains how to integrate PascalCoin into your exchange via the JSON API.
In PascalCoin there are two types of digital assets that can be exchanged.
- PASC this is the cryptocurrency and is the most common type of asset.
- PASA these are PascalCoin accounts, which are necessary to send and receive PASC.
Most exchanges will only trade PASC and not PASA. PASC can be exchanged in the same way other cryptocurrencies are. However, trading PASA is different since they are non-fungible assets. This means that some PASA are more valuable than others, due to their desirable numbers and/or names. For PASA exchanges, an auction-style market is recommended, such as PascWallet.
In order to support large numbers of users, exchanges do not require a PASA for each user. They are able to integrated PascalCoin into their exchange using a single PASA owned by the exchange which acts as a custodian account for all their users.
User deposits can be identified via a Payload Code inside the deposit transaction.
Step 1: Install PascalCoin
Installing PascalCoin is simple and can be installed on Linux or Windows. Minimum requirements are 1GB RAM, 2 CPU's and at least 10GB of storage.
The server should be isolated from public network and have the following ports opened publically:
- 4004: default PascalCoin network protocol port
Locally but not publically, the following ports should be opened
- 4003: default JSON-RPC port
Step 2: Set your wallet password
After installing the software, set a wallet password. By default the password is an empty string. *You can programmatically add/change the wallet password via setwalletpassword
method. If using the GUI, use the Options menu.
Step 3: Create your Exchange's key
In order to send/recieve PASC, you will need at least 1 key. This key will be associated to your exchange account (PASA).
On first run, PascalCoin will examine your wallet for keys and if none are found, it will add one for you.
You can also create a new key programatically using the addnewkey
method.
- For operational and maintanence simplicity, it's a good idea to name your key in a relevant way in order to avoid later confusion.
- Key names are only stored in the wallet and are not public.
- You will only really need 1 key for an exchange integration.
- Calling this method will generate a private/public key pair. The Private Key will be saved by PascalCoin internally. The Public Key is returned and accessible.
IMPORTANT PLEASE ENSURE YOUR WALLET AND KEYS ARE BACKED UP AT ALL TIMES.
NOTE: To programmatically determine the available keys in PascalCoin, you can use the getwalletpubkeys
method.
Step 4: Acquire your exchange account
In order to receive deposits and send withdrawals, your exchange will require an account (PASA). Getting an account is easy, and you can use:
- GetPasa: easily buy an account for 3 PASC
- PascWallet: an existing PASA exchange
- Use the wallets in-protocol PASA exchanging features. Many accounts are available for purchase directly in the network.
Step 5: Accepting user deposits
To accept deposits from users is easy. You need to instruct your users to include a PayloadCode inside their transaction to your exchange account. This PayloadCode can be used to identify the user.
Example
Exchange Account
Suppose the exchange account is 12345-67. All deposits and withdrawals operate through this account on the exchange.
Users Table
The user database contains a unique PayloadCode for each user.
ID | Name | PayloadCode | other fields | |
---|---|---|---|---|
523 | [email protected] | Bob | XH42SD | ... |
524 | [email protected] | Alice | S82DG2 | ... |
Deposit Details
- For Bob to deposit PASC into his exchange account he sends transactions to 12345-67 with payload XH42SD.
- For Alice to deposit PASC into her exchange account she sends transactions to 12345-67 with payload S82DG2.
Step 6: Scanning user deposits
Once your exchange is operational, you need to scan for deposits using same sort of workflow you would use for other cryptocurrencies.
How to scan
It can be done in many ways:
- Using
getaccountoperations
: If you're working in only 1 account, this can be a good option. Just scan your account every few minutes (or seconds) to obtain all related operations. An example should be callgetaccountoperations
with adepth
=10 and amax
=1000 and process received info - Using
getblockoperations
to scan what happened in a block and all related operations. If they match your account/s then update your info.
To know last blockchain block number, just call getblockcount
It's important to decode correctly all received operations, that are returned as a "Operations Object": https://github.com/PascalCoin/PascalCoin/wiki/JSON-RPC-API#operation-object
How to decode Payload
One important difference is to support both PUBLIC or ENCRYPTED payload codes in deposit transactions. This is required because some users may encrypt their payload and others may not. For example, users who withdraw from Poloniex directly to their deposit address on your exchange will always contain encrypted payloads. However, deposits from wallet users may be public. In principle, it is up to the recipient to examine the payloads both in their raw public form and then in their decrypted form.
As a result, when processing user deposit transactions to your exchange, it is highly recommended that you:
-
First check if the Operation Payload matches your users deposit code. If it matches, then the deposit can be accepted otherwise proceed to (2).
-
Decrypt the payload using
payloaddecrypt
method.
- Please note, if you restart your wallet and have changed the default password (empty) for a new password (recomended option), then you will need to call
unlock
method (only one time) prior to callpayloaddecrypt
, otherwise it will not be able to decrypt because wallet keys are locked.
- Repeat (1) using the decrypted payload code from (2). If it matches then deposit is accepted otherwise the deposit is unrecognised.
With this approach you can ensure deposits are never missed and that support requests are minimised.
Support
If for any reason you are experiencing difficulties, you may contact our development team on Discord or website.
Also, Sphere 10 Software offers free technical support for exchange listings of PascalCoin.