Skip to content

Instantly share code, notes, and snippets.

@Siimone
Created September 24, 2018 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Siimone/54a3a7be5848cce19b0d363aefcf96d1 to your computer and use it in GitHub Desktop.
Save Siimone/54a3a7be5848cce19b0d363aefcf96d1 to your computer and use it in GitHub Desktop.
Get transactions of IOTA address with Iota.lib.js
document.getElementById('search-transactions-js').addEventListener('click', function () {
let container = document.getElementById('transactions-js');
container.innerHTML = "";
let address = document.getElementById('iota-address-transactions-js').value
if (iota.valid.isAddress(address))
iota.api.findTransactionObjects(
{
addresses: [address]
}, function (err, res) {
if (err)
container.innerText = JSON.stringify(err);
if (res.length > 0) {
console.log(res)
document.getElementById('transactions-js').classList.remove('invisible');
document.getElementById('transactions-js').classList.add('visibile');
let ul = document.createElement("ul");
ul.classList.add('list-group');
for (let i = 0; i < res.length; i++) {
let child = document.createElement("li");
child.classList.add('list-group-item');
child.innerText = "Hash: " + res[i].hash + "\n";
child.innerText += "Nonce: " + res[i].nonce + "\n";
child.innerText += "Obsolete Tag: " + res[i].obsoleteTag + "\n";
child.innerText += "Tag: " + res[i].tag + "\n";
ul.appendChild(child)
}
container.appendChild(ul)
}
})
else
$('#wrong-address-modal').modal('show');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment