load account is working fine and giving details of accounts means horizon is giving response but on transaction submitting getting error.
local node setup done using docker image of stellar
code
app.get('/transferCoins', async function (req, res) {
var sourceSecretKey = issuer.secret;// seed of acc from which tx process
var sourceKeypair = StellarSdk.Keypair.fromSecret(sourceSecretKey);
var sourcePublicKey = sourceKeypair.publicKey();//pub key of source acc
var receiverPublicKey = account2.publicKey;// public key of reciever acc
StellarSdk.Network.useTestNetwork();
console.log('1');
//var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');//live netwrk
var server = new StellarSdk.Server('http://localhost:8000', {allowHttp: true});
console.log('2');
const account = await server.loadAccount(sourcePublicKey)
console.log('3');
var transaction = new StellarSdk.TransactionBuilder(account)
.addOperation(StellarSdk.Operation.payment({
destination: receiverPublicKey,
asset: StellarSdk.Asset.native(),//native asset lumen
amount: '0.1',
}))
.addMemo(StellarSdk.Memo.text('coins sent xlm'))//optional
.build();
console.log('4');
transaction.sign(sourceKeypair);
const temp = await server.submitTransaction(transaction)
console.log('submitted', temp._links);
});
output
1
2
3
4
(node:23113) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): **Error: Request failed with status code 504**
(node:23113) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.