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()
       .to(address, satoshis)

      var tx = transaction.toString()

1 Answer 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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.