<p>Your transaction is not signed. You need to call <code>.sign</code> last since changing the transaction after signing will invalidate the signatures and thus bitcore will remove them. You should instead be doing:</p>

<pre><code>var transaction = new bitcore.Transaction()
.from({"address":"msxGdsTJJYu7YrmkV4sbHNK8Z21pHFZ2gX","txid":"0c0d9ad92f07e774a76194823a92bf2521aa57381ad4782becf20fdf385e1922","vout":0,"scriptPubKey":"76a914886b382436985b195d1dfcdb00c722c1f2fcd0ea88ac","amount":0.01})
.to('mjsVogqLetdUjT9raJY6WgYmy3tifJ3DJz', 20000)
.change('mhCpGNNHQmu4P9pUZcCmgXkxbYxys5pKBw');
.sign('0497427ad1b6177fe950758f10151ba38a6b38d44577ba45fb06423143bb55a2')
</code></pre>

CC BY-SA 3.0
2018-01-20T04:59:18.170Z
Getting same error after adding a sign.
kiran malvi
CC BY-SA 3.0
2018-01-19T19:10:48.640Z
2018-01-19T19:10:48.640Z
Ava Chow
<p>I have tried to create transaction and broadcast transaction but I am not able to do this stuff.</p>

<p>Let me share with you code.</p>

<pre><code>var transaction = new bitcore.Transaction()
    .from({"address":"msxGdsTJJYu7YrmkV4sbHNK8Z21pHFZ2gX","txid":"0c0d9ad92f07e774a76194823a92bf2521aa57381ad4782becf20fdf385e1922","vout":0,"scriptPubKey":"76a914886b382436985b195d1dfcdb00c722c1f2fcd0ea88ac","amount":0.01})
    .to('mjsVogqLetdUjT9raJY6WgYmy3tifJ3DJz', 20000)    .sign('0497427ad1b6177fe950758f10151ba38a6b38d44577ba45fb06423143bb55a2')
    .change('mhCpGNNHQmu4P9pUZcCmgXkxbYxys5pKBw');

var txSerialized = transaction.serialize(true);
console.log(txSerialized);
var Insight = require('bitcore-explorers');
var client = new Insight.Insight();
client.broadcast(txSerialized, function(err, txId) { console.log('Id:', txId, err);})
</code></pre>

<p><em>Getting below output:</em></p>

<pre><code>010000000122195e38df0ff2ec2b78d41a3857aa2125bf923a829461a774e7072fd99a0d0c0000000000ffffffff02204e0000000000001976a9142fc320597ba67a66167721bc9c36d987e03c225b88ac806d0d00000000001976a91412820fdb8340e5198b3c31de5688faa7927b0d7188ac00000000
Id: undefined Missing inputs. Code:-25
</code></pre>

<p>I have tried many things but I am not able to solve it.</p>

<p>Can you please give me the solution or proper demo for it with a full description?</p>

<bitcoind><bitcore>
Bitcore Insight API: I am not able to create and broadcast transaction
kiran malvi
# Bitcore Insight API: I am not able to create and broadcast transaction

(Asked by: username_0 on 2018-01-19)

I have tried to create transaction and broadcast transaction but I am not able to do this stuff.

Let me share with you code.

```
var transaction = new bitcore.Transaction()
    .from({"address":"msxGdsTJJYu7YrmkV4sbHNK8Z21pHFZ2gX","txid":"0c0d9ad92f07e774a76194823a92bf2521aa57381ad4782becf20fdf385e1922","vout":0,"scriptPubKey":"76a914886b382436985b195d1dfcdb00c722c1f2fcd0ea88ac","amount":0.01})
    .to('mjsVogqLetdUjT9raJY6WgYmy3tifJ3DJz', 20000)    .sign('0497427ad1b6177fe950758f10151ba38a6b38d44577ba45fb06423143bb55a2')
    .change('mhCpGNNHQmu4P9pUZcCmgXkxbYxys5pKBw');

var txSerialized = transaction.serialize(true);
console.log(txSerialized);
var Insight = require('bitcore-explorers');
var client = new Insight.Insight();
client.broadcast(txSerialized, function(err, txId) { console.log('Id:', txId, err);})

```

*Getting below output:*

```
010000000122195e38df0ff2ec2b78d41a3857aa2125bf923a829461a774e7072fd99a0d0c0000000000ffffffff02204e0000000000001976a9142fc320597ba67a66167721bc9c36d987e03c225b88ac806d0d00000000001976a91412820fdb8340e5198b3c31de5688faa7927b0d7188ac00000000
Id: undefined Missing inputs. Code:-25

```

I have tried many things but I am not able to solve it.

Can you please give me the solution or proper demo for it with a full description?

**Tags:** bitcoind, bitcore


---

## 1 answers

### Answer by username_1 on 2018-01-19. Score: 1 | Accepted answer

Your transaction is not signed. You need to call `.sign` last since changing the transaction after signing will invalidate the signatures and thus bitcore will remove them. You should instead be doing:

```
var transaction = new bitcore.Transaction()
.from({"address":"msxGdsTJJYu7YrmkV4sbHNK8Z21pHFZ2gX","txid":"0c0d9ad92f07e774a76194823a92bf2521aa57381ad4782becf20fdf385e1922","vout":0,"scriptPubKey":"76a914886b382436985b195d1dfcdb00c722c1f2fcd0ea88ac","amount":0.01})
.to('mjsVogqLetdUjT9raJY6WgYmy3tifJ3DJz', 20000)
.change('mhCpGNNHQmu4P9pUZcCmgXkxbYxys5pKBw');
.sign('0497427ad1b6177fe950758f10151ba38a6b38d44577ba45fb06423143bb55a2')

```

> **Comments:**
> **username_0**: Getting same error after adding a sign.  

---

