0

I am following this question answer Trying to implement the answer BUt my transaction is getting failed. Am i doing any mistakes in the implementation part?

  var sendr = Stellar.Keypair.fromSecret('SA43Z6BF57K6SQNN3ZWPSTVZR6QQWVK4ORUJWG5BEBPH4VKFQIQGJ5M3');


  var receivr = 'GAJAG2J2EQ2KUVE5B57JKEKC6WW4G3VEYBXV7FGM2HKZPQ7M5P25HZKW';

   // Create an object to represent the new asset
  var fnew = new Stellar.Asset('FRI', 'GDPSCSBLYQU4TXNPLTDFB2JUIZRQQ5CL2E2NYT5J76MUFEO2CP7S3MMF');

  server.loadAccount(sendr.publicKey())
 .then(function(issuer) {

  var preAuthTx = new Stellar.TransactionBuilder(issuer, opts={fee:1}, issuer.sequence=issuer.sequence+2, timebounds= { minTime: 1560763800})
  .addOperation(Stellar.Operation.payment({
    destination: receivr,
    asset: fnew,
    amount: '20'
}))
  .addOperation(Stellar.Operation.changeTrust({
       asset: fnew,
      limit: '0'
  }))
  .addOperation(Stellar.Operation.accountMerge({
    destination: receivr
}))
.setTimeout(100)
  .build();


  var transaction = new Stellar.TransactionBuilder(issuer, opts={fee:1})
.addOperation(Stellar.Operation.setOptions({
  signer: {
      preAuthTx: preAuthTx.hash(),
      weight: 1
    }
   }))
  .addOperation(Stellar.Operation.setOptions({
masterWeight: 0
  }))


  // setTimeout is required for a transaction
  .setTimeout(100)
  .build();
 transaction.sign(sendr);
  return server.submitTransaction(transaction);
  })
    .then(function(result) {
console.log('Successin sending assets', result);
 })
 .catch(function(error) {
console.error('Error in sending assets', error);
});
3
  • At a quick glance: changeTrust expects asset, limit, [source] as parameters, so that surely won't work. Besides console.log(error.response.data.extras); will give you more insight to errors.
    – sui
    Jun 17, 2019 at 18:11
  • @sui thanks for picking out changeTrust limit thing. i have corrected it. in the response it is showing "tx_bad_seq" error.
    – Suman Raj
    Jun 18, 2019 at 5:37
  • your pre-auth tx needs to have a higher sequence number than the tx you use do add it as a signer, since the pre-auth tx will be submitted to the network after it. Jun 20, 2019 at 8:59

0

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.

Browse other questions tagged or ask your own question.