When I try to broadcast a transaction, I'm having this error:

throw new errors.InvalidArgument(argumentName, message, docsPath);       
Invalid Argument Error
at NodeError (/home/aziz/node_modules/bitcore-explorers/node_modules/bitcore-lib/lib/errors/index.js:20:41)
at Object.checkArgument (/home/aziz/node_modules/bitcore-explorers/node_modules/bitcore-lib/lib/util/preconditions.js:14:13)
at Insight.broadcast (/home/aziz/node_modules/bitcore-explorers/lib/insight.js:96:5)
at /home/aziz/node_modules/megachain-bitcoin.js:39:12
at Request._callback (/home/aziz/node_modules/bitcore-explorers/lib/insight.js:80:12)
at Request.self.callback (/home/aziz/node_modules/bitcore-explorers/node_modules/request/request.js:188:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:194:7)
at Request.<anonymous> (/home/aziz/node_modules/bitcore-explorers/node_modules/request/request.js:1171:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:191:7)
at IncomingMessage.<anonymous> (/home/aziz/node_modules/bitcore-explorers/node_modules/request/request.js:1091:12)
at Object.onceWrapper (events.js:293:19)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:188:7)
at endReadableNT (_stream_readable.js:975:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)

And this is my code:

var bitcore = require('bitcore-lib');
var explorers = require('bitcore-explorers');
var insight = new explorers.Insight('testnet');

    var sendBTC = function (SenderPrivateKey, SenderAddress, ReceiverAddress, Amount) //adresses in string format
        SenderPrivateKey = new bitcore.PrivateKey(SenderPrivateKey,'testnet');
        ReceiverAddress = new bitcore.Address(ReceiverAddress,'testnet');
        SenderAddress = SenderPrivateKey.toAddress();

        insight.getUnspentUtxos(SenderAddress, function(err, utxos) {
            if (err) {
            } else {
                var tx = bitcore.Transaction();
                tx.to(ReceiverAddress, 500000);

                insight.broadcast(tx, function(err, txId) {
                    if (err) {
                    } else {
                        console.log('Successfully sent: '+txId);


Can someone help me? thanks!

  • remove the insight.getUnspentUtxos and check if you get a log for your console.log(SenderPrivateKey); Jun 7, 2017 at 0:56
  • @Everblack you solved it?
    – Suisse
    Oct 13, 2017 at 17:28
  • @Everblack : You got any solution then please let me know, because i am also facing same issue, but in my case if i am sending btc to bitcore generated address then it working, if i am sending other testnet address then it'll give serializationError Apr 27, 2018 at 7:38

1 Answer 1


Either create the transaction using constructor:

var transaction = new Transaction();

or pass serialized transaction to broadcast method:

insight.broadcast(tx.serialize(), ......
  • 1
    The second suggestion worked for me. Thanks.
    – dev.bv
    Oct 18, 2018 at 12:32

Your Answer

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

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