<p>Users don't have addresses at exchanges. When you deposit to the exchange you're depositing to the exchanges wallet, with a unique address just enabling them to account for who to credit the internal balance to. Withdraws only require one on chain transaction, just debiting the amount from the database and then sending that value to the address requested.</p>

CC BY-SA 4.0
2021-02-16T04:52:57.990Z
How can exchanges generate an address that sending exchanges know is a wallet but at the same time be unique to the receiving exchanges entire database?
Trevor
CC BY-SA 4.0
2021-02-16T04:53:46.063Z
i.e. One wallet can have multiple (millions) of different possible addresses?
Trevor
CC BY-SA 4.0
2021-02-16T06:06:27.190Z
There’s no limit to the number of addresses in a wallet.
Claris
CC BY-SA 4.0
2021-02-16T06:14:08.330Z
Whattttttttttt. mindblown. okay I need to read up more on bitcoin then. thanks for the info!
Trevor
CC BY-SA 4.0
2021-02-17T00:38:39.223Z
You may find https://bitcoin.stackexchange.com/q/8804/5406 interesting.
Murch
CC BY-SA 4.0
2021-02-16T04:36:20.460Z
2021-02-16T04:36:20.460Z
Claris
<p>This is how it generally works.</p>
<ol>
<li>When a user clicks &quot;deposit&quot; button first time, The exchange calls the BTC node with getnewaddress command to generate the address, and displays it to user.</li>
<li>User makes the deposit to that address.</li>
<li>Bitcoin has walletNotify feature, so when the deposit hits the exchange node, it will notify the exchange API with transactionHash.</li>
<li>Taking that txHash, exchange will call getTransaction API of bitcoin node and get all details of the transaction, including deposit wallet address.</li>
</ol>
<p>Now coming back to your question.</p>
<p>Once the exchange has met the confirmation requirement, it will simply update their local Database (Mongo/MySQL or any other) with relevant deposit details. Now when user 1 sends BTC to user 2 on same exchange, there is no onchain transaction.</p>
<p>Exchange just deducts the withdrawal amount from user 1 database, and credits the same to user 2 database.</p>
<p>But when the user inputs a withdrawal address outside of exchange, that is when actual blockchain transaction takes place.</p>

CC BY-SA 4.0
2021-02-16T06:30:01.977Z
2021-02-16T06:30:01.977Z
Gladiator9120
<p>So I understand that exchanges don't have to perform updates on the blockchain. However I'm not sure how they figure out the following solution without having to pay blockchain fees? I guess they do</p>
<p>i.e.</p>
<ol>
<li>An exchange gives 3 users, Bill, Jane &amp; Sally a BTC address.</li>
<li>Bill &amp; Jane both send in 0.001 BTC to that address from a different exchange/wallet.</li>
<li>Now Bill &amp; Jane both send 0.0005 BTC to Sally on the same exchange. Same exchange so this doesn't have to be on the chain.</li>
<li>So now Bill &amp; Jane both have 0.0005 BTC and Sally has 0.001 BTC according to the exchange. However both Bill &amp; Jane's actual wallet address still has 0.001.</li>
<li>Sally now withdraws her 0.001 BTC</li>
</ol>
<p>The exchange now needs to perform two blockchain updates to fulfill this withdraw which means two transaction fees on the blockchain for the exchange.</p>
<p>Does anybody know how exchanges do this?</p>

<exchanges>
How do exchanges provide wallets unique wallets to users but also keep transaction fees low?
Trevor
# How do exchanges provide wallets unique wallets to users but also keep transaction fees low?

(Asked by: username_0 on 2021-02-16)

So I understand that exchanges don't have to perform updates on the blockchain. However I'm not sure how they figure out the following solution without having to pay blockchain fees? I guess they do

i.e.

1. An exchange gives 3 users, Bill, Jane & Sally a BTC address.
2. Bill & Jane both send in 0.001 BTC to that address from a different exchange/wallet.
3. Now Bill & Jane both send 0.0005 BTC to Sally on the same exchange. Same exchange so this doesn't have to be on the chain.
4. So now Bill & Jane both have 0.0005 BTC and Sally has 0.001 BTC according to the exchange. However both Bill & Jane's actual wallet address still has 0.001.
5. Sally now withdraws her 0.001 BTC

The exchange now needs to perform two blockchain updates to fulfill this withdraw which means two transaction fees on the blockchain for the exchange.

Does anybody know how exchanges do this?

**Tags:** exchanges


---

## 2 answers

### Answer by username_1 on 2021-02-16. Score: 3 | Accepted answer

Users don't have addresses at exchanges. When you deposit to the exchange you're depositing to the exchanges wallet, with a unique address just enabling them to account for who to credit the internal balance to. Withdraws only require one on chain transaction, just debiting the amount from the database and then sending that value to the address requested.

> **Comments:**
> **username_0**: How can exchanges generate an address that sending exchanges know is a wallet but at the same time be unique to the receiving exchanges entire database?  
> **username_0**: i.e. One wallet can have multiple (millions) of different possible addresses?  
> **username_1**: There’s no limit to the number of addresses in a wallet.  
> **username_0**: Whattttttttttt. mindblown. okay I need to read up more on bitcoin then. thanks for the info!  
> **username_2**: You may find https://bitcoin.stackexchange.com/q/8804/5406 interesting.  

---

### Answer by username_3 on 2021-02-16. Score: 1

This is how it generally works.

1. When a user clicks "deposit" button first time, The exchange calls the BTC node with getnewaddress command to generate the address, and displays it to user.
2. User makes the deposit to that address.
3. Bitcoin has walletNotify feature, so when the deposit hits the exchange node, it will notify the exchange API with transactionHash.
4. Taking that txHash, exchange will call getTransaction API of bitcoin node and get all details of the transaction, including deposit wallet address.

Now coming back to your question.

Once the exchange has met the confirmation requirement, it will simply update their local Database (Mongo/MySQL or any other) with relevant deposit details. Now when user 1 sends BTC to user 2 on same exchange, there is no onchain transaction.

Exchange just deducts the withdrawal amount from user 1 database, and credits the same to user 2 database.

But when the user inputs a withdrawal address outside of exchange, that is when actual blockchain transaction takes place.


---

