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);
});