Stellar Asked by newdev on August 21, 2021
Using Stellar’s Javascript SDK
Output an array containing all the memos:
['324567567', 'anotherMemo', '239210923', '2349028509']
This array will be used to check against a database and confirm transactions.
I have isolated the memos from every transaction; although, the output is delineated by newlines. My attempts with join()
and a for-loop are unsuccessful.
var StellarSdk = require('stellar-sdk');
var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');
const hostAccountId = "GDUBG6QT24UYGBIAKRIVDA776STGIFM4XMHTAYGHOSCR44JIKN64JDKG" // Load hostAccountId from database ("test value")
server.transactions()
.forAccount(hostAccountId)
.limit(200)
.order('desc')
.call()
.then(function (page) {
page.records.forEach( function(record) {
if (record.memo === undefined) {} else {
var memo;
memo = (record.memo);
console.log(memo);
}
});
})
.catch(function (err) {
console.log(err);
});
Output:
18446744073709551615
12345678910
Another Memo
Special Memo only
What does this memo say
I am very new to Javascript and to programming on Stellar. Thank you for your time!
Instantiate an empty array with
let memos = [];
And add an element with the push method.
memos.push( memo );
Snippet:
let memos = [];
page.records.forEach( function(record) {
if (record.memo === undefined) {} else {
var memo;
memo = (record.memo);
memos.push(memo);
}
})
console.log(memos);
Correct answer by sui on August 21, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP