<p>When you create a transaction, all inputs are used up completely. </p>

<p>You then have to specify the destination addresses of the input money. Any amount without destination becomes available as transaction fee. Hence, you have to define the recipient, and <strong><a href="https://bitcoin.stackexchange.com/q/736/5406">send back the change to yourself</a></strong>.</p>

<p><strong>In other words, add one of your own addresses as a second destination and assign the remainder of your inputs there.</strong></p>

<p>If you haven't been doing so, you should experiment with transaction creation on the <strong>testnet</strong>. There you can learn without cost, because it behaves like Bitcoin, but its tokens are worthless.</p>

CC BY-SA 3.0
2015-07-13T13:13:57.437Z
2015-07-13T13:42:51.493Z
2017-04-13T12:47:33.283Z
Murch
<p>I've been learning to create bitcoin transactions for 3 weeks now, but keep paying the entire <strong>unspent_outputs</strong> - <strong>inputs</strong> as fees, even if the transacted amount was like 1/100 th of the outputs. How do I put the unspent output back into the output address ?</p>

<pre><code>      var utxo = {
                   "txId" : "",
                   "outputIndex" : "",
                   "address" : "",
                   "script" : "",
                   "satoshis" : ""
                 }

       var transaction = new bitcore.Transaction()
       .from(utxo)
       .to(address, satoshis)
       .sign(privateKeyWIF);

      var tx = transaction.toString()
</code></pre>

<transactions><raw-transaction><change><utxo>
How to return change (utxo - inputs) to output address?
sl0vaj
# How to return change (utxo - inputs) to output address?

(Asked by: username_0 on 2015-07-13)

I've been learning to create bitcoin transactions for 3 weeks now, but keep paying the entire unspent_outputs - inputs as fees, even if the transacted amount was like 1/100 th of the outputs. How do I put the unspent output back into the output address ?
      var utxo = {
                   "txId" : "",
                   "outputIndex" : "",
                   "address" : "",
                   "script" : "",
                   "satoshis" : ""
                 }

       var transaction = new bitcore.Transaction()
       .from(utxo)
       .to(address, satoshis)
       .sign(privateKeyWIF);

      var tx = transaction.toString()

**Tags:** transactions, raw-transaction, change, utxo


---

## 1 answers

### Answer by username_1 on 2015-07-13. Score: 1

When you create a transaction, all inputs are used up completely.

You then have to specify the destination addresses of the input money. Any amount without destination becomes available as transaction fee. Hence, you have to define the recipient, and **[send back the change to yourself](https://bitcoin.stackexchange.com/q/736/5406)**.

**In other words, add one of your own addresses as a second destination and assign the remainder of your inputs there.**

If you haven't been doing so, you should experiment with transaction creation on the **testnet**. There you can learn without cost, because it behaves like Bitcoin, but its tokens are worthless.


---

