Skip to content

Instantly share code, notes, and snippets.

@w3kim
Created October 18, 2019 01:03
Show Gist options
  • Save w3kim/f393c4144b7c98c7bb04059c373f65d2 to your computer and use it in GitHub Desktop.
Save w3kim/f393c4144b7c98c7bb04059c373f65d2 to your computer and use it in GitHub Desktop.
Filtering transactions that are included in a block
const Caver = require('caver-js');
const caver = new Caver('https://api.baobab.klaytn.net:8651/');
// getBlock's second parameter is boolean; if true, getBlock returns a block with transaction objects.
caver.klay.getBlock(9660831, true).then((resp) => {
const { transactions } = resp;
const filtered = transactions.filter((e) => { return e['to'] === 'address_you_are_looking_for' });
console.log(filtered);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment