I am trying to send a payment on stellar testnet. I have already created both accounts using https://friendbot.stellar.org. So both account have a balance. When I am sending payment it is showing "Something went wrong!" but no error is showing. I have checked the code and found that upon calling build() the program throws an error, which is caught in the catch block. Could anyone tell me what error could be thrown by the build function?

var StellarSdk = require('stellar-sdk');


var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');

var sourceKeys = StellarSdk.Keypair

// Transaction will hold a built transaction we can resubmit if the result is unknown.

var transaction;

// First, check to make sure that the destination account exists.
// You could skip this, but if the account does not exist, you will be charged
// the transaction fee when the transaction fails.

  // If the account is not found, surface a nicer error message for logging.

  .catch(StellarSdk.NotFoundError, function (error) {

    throw new Error('The destination account does not exist!');


  // If there was no error, load up-to-date information on your account.
  .then(function() {

    return server.loadAccount(sourceKeys.publicKey());

  .then(function(sourceAccount) {

    // Start building the transaction.

    transaction = new StellarSdk.TransactionBuilder(sourceAccount)


        destination: destinationId,

        // Because Stellar allows transaction in many currencies, you must
        // specify the asset type. The special "native" asset represents Lumens.

        asset: StellarSdk.Asset.native(),

        amount: "10"


      // A memo allows you to add your own metadata to a transaction. It's
      // optional and does not affect how Stellar treats the transaction.

      .addMemo(StellarSdk.Memo.text('Test Transaction'))


    // Sign the transaction to prove you are actually the person sending it.


    // And finally, send it off to Stellar!

    return server.submitTransaction(transaction);


  .then(function(result) {

    console.log('Success! Results:', result);


  .catch(function(error) {

    console.error('Something went wrong!', error);

    // If the result is unknown (no response body, timeout etc.) we simply resubmit

    // already built transaction:

    // server.submitTransaction(transaction);


Not sure why you think it's thrown by build() Usually errors are thrown when you try to submit invalid transaction.

you're dumping whole error object, that's why you can't see what's on 3rd nesting level of response you're getting from horizon.

if you dig down in your error handling to

.catch(function(error) {
    console.error('Something went wrong!', error.response.data.extras);

you will be able to see response from horizon:

  result_codes: { transaction: 'tx_failed', operations: [ 'op_underfunded' ] },

['op_underfunded'] is what we've been looking for

This error message means you don't have enough funds to send this amount

Your source account for the secret key that you posted GC2BKLYOOYPDEFJKLKY6FNNRQMGFLVHJKQRGNSSRRGSMPGF32LHCQVGF

currently has 1.8833 XLM, which is not enough to send 10.

  • wlhen i am using error.response.data.extras then i am getting error Cannot read property 'data' of undefined. Feb 14 '19 at 8:42
  • I am sending payment from secret key "SAOUNYUBZDO3T3BIS2TC4W3TD6T5K5LQMQYKYQHJZYCEVS2KEG52OWA4" to destination key "GDSQT7FFLLVVU2KW33D52DIOGDGPXCK5HVHMLOBAF6YY5VKUKFFETFXF". on testnet Feb 14 '19 at 8:46
  • could you send me verified code for send transactions with above keys ? Feb 15 '19 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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