Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: usmerk66 on March 15, 2023, 04:15:58 PM



Title: Many adresses for many coins. Building exchange
Post by: usmerk66 on March 15, 2023, 04:15:58 PM
Im making an exchange like sideshift.ai.
I have 2 questions.


1. How do i generate a new deposit adress for each new user and each coin?

Like if you want to exchange BTC to ETH, you will get a BTC adress/QR code to send to.
But that unique adress needs to go to my binance account, or at least the deposit has to go to binance account. 
Is there like any API or so that generates sub adresses and then binding them all to my static btc adress on binance?

2. When a user send crypto to the deposit adress, he will get a notification that they are accepted by the blockchain network.
 Something like:
" thanks for your deposit, We will now exchange your BTC and send 0.124 ETH  to your wallet. You can now close your browser if you want".


I will have like 50 different coins in total, so not only BTC and ETH.



Title: Re: Many adresses for many coins. Building exchange
Post by: OmegaStarScream on March 15, 2023, 04:23:54 PM
AFAIK, there's no way to generate a new address using Binance API.

What you need to do is run your own node, and communicate with it.

1. A user chooses the trading pairs.
2. You generate a bitcoin address for him.
3. Wait for a certain number of confirmations.
4. Send him the money.

I understand what you're trying to do, and one solution would be to once you're done with #3, you transfer the funds directly to Binance, and from there, you can exchange the funds and withdraw them however, I don't think this is the best solution because it will result into a very bad experience (since the user has to wait more than he should).

It's better to have some liquidity aside on Binance at first if this is how you want to do it and instead of sending each transaction you receive directly to Binance, you wait until you get a few, then batch everything to Binance. This should also save you some fees.


Title: Re: Many adresses for many coins. Building exchange
Post by: LoyceV on March 15, 2023, 04:38:16 PM
Im making an exchange
~
How do i generate a new deposit adress for each new user
If you have to ask this, you shouldn't build an exchange.


Title: Re: Many adresses for many coins. Building exchange
Post by: usmerk66 on March 15, 2023, 05:35:17 PM
Im making an exchange
~
How do i generate a new deposit adress for each new user
If you have to ask this, you shouldn't build an exchange.

Wow, you are talking so much shit.

Its not rocketscience making a small exchange, and its even easier to maintain when its all set up.

It like i would say" if you have to ask how to fix a car, you shouldnt drive one".


Title: Re: Many adresses for many coins. Building exchange
Post by: usmerk66 on March 15, 2023, 05:54:54 PM
AFAIK, there's no way to generate a new address using Binance API.

What you need to do is run your own node, and communicate with it.

1. A user chooses the trading pairs.
2. You generate a bitcoin address for him.
3. Wait for a certain number of confirmations.
4. Send him the money.

I understand what you're trying to do, and one solution would be to once you're done with #3, you transfer the funds directly to Binance, and from there, you can exchange the funds and withdraw them however, I don't think this is the best solution because it will result into a very bad experience (since the user has to wait more than he should).

It's better to have some liquidity aside on Binance at first if this is how you want to do it and instead of sending each transaction you receive directly to Binance, you wait until you get a few, then batch everything to Binance. This should also save you some fees.

The user will have a uniqe order-id, so i was thinking if i could log that, plus his reciving adress and the amount he sent.
Then i would get notification when his coins arrive to my binance account and then just send him back 5% less ETH if i charged a 5% fee.

But he still would not get any notification that i have recived his coins while he is waiting or me to complete the exchange. 


I like you 1-4 description, thats exactly how i want it to work.
Do i need a node for each coin, like if i have 50 different coins, do i need a node for each one?
And what could that cost?





Title: Re: Many adresses for many coins. Building exchange
Post by: OmegaStarScream on March 16, 2023, 02:48:33 PM
The user will have a uniqe order-id, so i was thinking if i could log that, plus his reciving adress and the amount he sent.
Then i would get notification when his coins arrive to my binance account and then just send him back 5% less ETH if i charged a 5% fee.

But he still would not get any notification that i have recived his coins while he is waiting or me to complete the exchange. 

I like you 1-4 description, thats exactly how i want it to work.
Do i need a node for each coin, like if i have 50 different coins, do i need a node for each one?
And what could that cost?

You should first confirm if Binance allows generating multiple addresses but as I said, I don't believe they do and even if they did, you will probably need to deal with the API limits as well, which doesn't help either.

The approach is correct though.
You create an address for the user and link it with the OrderID -> Wait until the address receives a transaction -> check for the amount -> wait for a few confirmations -> notify the user.

And yes, you would need different nodes for different coins. But if you're going to deal mainly with evm compatible networks then I would suggest you look into Alchemy, Infura, and Quicknode. They all have free tiers (there are limits on how many requests you can make, but it's still good) so maybe you can start with that at first and then upgrade.

As for your comment above, then yes, an instant exchange like Sideshift may be easier to develop and maintain compared to a CEX, but you should still take security seriously.


Title: Re: Many adresses for many coins. Building exchange
Post by: Learn Bitcoin on March 16, 2023, 05:32:00 PM
Would you mind doing your own research about block.io (http://block.io)
I feel like this wallet website could meet your needs.


Title: Re: Many adresses for many coins. Building exchange
Post by: odolvlobo on March 17, 2023, 03:53:40 AM
I'm curious why Binance, which is an exchange, needed for your exchange.

Off the top of my head, here is a summary of how to create a simple exchange where you set the prices instead of using a market (because it is easier).

  • 1. Create a wallet for each kind of coin.
  • 2. Create a database for trades. Each entry would contain the amounts for each coin and their receiving addresses.
  • 3. Create a site that allows a person to create a trade.
    • 3a. The site gets an address from the wallet for the coin the customer is sending and shows it to the customer.
    • 3b. The set gets an address from customer for the coins the customer is buying.
    • 3c. The site records the transaction in the database.
  • 4. Create a backend that periodically scans the transaction database, gets the receiving addresses for the pending trades and checks the wallets to see if the coins have arrived. When the coins for a trade have arrived, it sends the customer's coins to the address they provided.

There you go. No need for Binance. Is that what you are doing?


Of course, I'm sure that there is a lot more involved in the implementation. You don't want to get hacked or end up like Mt. Gox.


Title: Re: Many adresses for many coins. Building exchange
Post by: usmerk66 on March 17, 2023, 09:03:00 PM
I'm curious why Binance, which is an exchange, needed for your exchange.

Off the top of my head, here is a summary of how to create a simple exchange where you set the prices instead of using a market (because it is easier).

  • 1. Create a wallet for each kind of coin.
  • 2. Create a database for trades. Each entry would contain the amounts for each coin and their receiving addresses.
  • 3. Create a site that allows a person to create a trade.
    • 3a. The site gets an address from the wallet for the coin the customer is sending and shows it to the customer.
    • 3b. The set gets an address from customer for the coins the customer is buying.
    • 3c. The site records the transaction in the database.
  • 4. Create a backend that periodically scans the transaction database, gets the receiving addresses for the pending trades and checks the wallets to see if the coins have arrived. When the coins for a trade have arrived, it sends the customer's coins to the address they provided.

There you go. No need for Binance. Is that what you are doing?


Of course, I'm sure that there is a lot more involved in the implementation. You don't want to get hacked or end up like Mt. Gox.



I keep my funds on a exchange, and i need an exchange to be able to echange the users crypto that is sent to me.

How would i exchange the users crypto for like 1% fee if i didnt use an exchange?


Title: Re: Many adresses for many coins. Building exchange
Post by: odolvlobo on March 18, 2023, 05:49:20 AM
I keep my funds on a exchange, and i need an exchange to be able to echange the users crypto that is sent to me.

How would i exchange the users crypto for like 1% fee if i didnt use an exchange?

If you keep your funds in your own wallets, then you don't need an exchange. And charging 1% is easy. If the pair trades at 1 to 100, then you exchange at 1 to 99 or 1 to 101.

But I see what you are doing. You don't want to hold any inventory and you want to act as a broker between the customer and the exchange.

Many wallets do what you want to do. They set up a relationship with an exchange that allows them to be a broker. Checkout Binance Connect (https://www.binancecnt.com/en/business/partner-us)