Add Kaspa to your exchange

This tutorial describes how to add Kaspa's native currency KAS to your cryptocurrency exchange.

This tutorial uses kaspawalletd in base.

Firstly you need a synchronized node for interacting with network, you can use a public node but it wont be reliable such as your private node.

Creating deposit account

Create an unique address for every depositer using kaspawalletd's NewAddress function.

We suggest moving some fund of hot wallets to cold wallets for extra security.

Listening for deposits

Using subscriptions

Firstly, subscribe for notifyBlockAddedRequest and notifyVirtualSelectedParentChainChangedRequest(with includeAcceptedTransactionIds).

Secondly, cache block contents comes from notifyBlockAddedRequest and filter&cache deposit transactions from block.

On notifyBlockAddedRequest

If acceptedTransactionIds includes any pending deposit, save acceptingBlockHash for transaction.

If any pending deposit included on removed blocks, remove acceptingBlockHash from transaction.

Get virtual parent by addedChainBlockHashes's last entry and get blue score of virtual parent by fetching block's contents from block cache, a pending deposits confirmations will be blue score - deposit's acceptingBlock's blue score + 1

Finally, when the confirmations of a deposit transaction reaches 1200, it is safe to believe the deposit is complete.

Sending withdrawals

Use kaspawalletd's Send function with amount & address.

Dont forget to check address before using send function, it could crash kaspawalletd!

Examples

Last updated