Search code examples
node.jsblockchainbitcoincoinbase-apicryptocurrency

How to develop a crypto exchange leveraging on third party API like coinbase, blockchain.com


I got a request as a developer to develop a bitcoin exchange site like https://mypatricia.co/ or https://instantcoins.ng/ I am to leverage on third party API like Coinbase, blockchain, it could be anything reliable API.

Users will be able to buy and sell bitcoin. For instance USER A makes an offer. USER B is interested in USER A's offer. When USER B clicks a button, with be a switch from USER A's wallet to USER B's wallet. Before the EXCHANGE is done. USER B is prompted to make payment in local currency.

I have been looking at https://developers.coinbase.com/api/v2#introduction https://api.blockchain.com/v3 I dont know how to go about it.

Is there any other better ones to work with?

There will be some other endpoints like

  • Where users get list of their orders
  • check wallet etc

I will appreciate your contribution


Solution

  • This is a very broad topic, so I'm just going to tackle few key points.

    Dependency on third-party blockchain data

    • You can get rate limited
    • You might be a subjet to a man-in-the-middle attack
    • The source might (intentionally or unintentionally) send incorrect data.
    • The data is usually delayed
    • You'll most likely need to use another tool to create deposit addresses (since the third-party tools will allow you to create only limited amount of addresses on your account).

    It's very risky and unreliable to use a third-party data. It's an industry standard to run a full node for each cryptocurrency you work with and access the blockchain data from your own node instead of a third-party API.

    Escrowing the offered amount

    As per your example, you need to make sure that user A is actually going to transfer the BTC. Since there are no smart contracts in BTC, you need to act as an escrow.

    So you need to accept the BTC from user A to their deposit address (only your site should have the private key to this address) before you even allow them to pass their order into the queue.

    Order list

    Since you're going to be storing the order list on your side, you need to create a separate database and CRUD endpoints to maintain the order list.