1

I'm trying to get each transactions from response of txpool.getContent().

The response structure is here.

> pending: {
'0x0000000186c96Ab17A967d7A3033db82efcA587B': { '11': [Object] },
'0x00000004888f25bb2a792e78D5a6dF392d59e140': { '39': [Object] },
'0x000000057c695b6Af389Ff5b7542c7e01333981A': { '13': [Object] },
'0x000000084115EdEB2c9484b490F7AC89F8980E5F': { '12': [Object] },
'0x000000086aD594b50486A68246D506E5DE24EBD8': {
  '12087': [Object],
  '12088': [Object],
  '12089': [Object],
  '12090': [Object],
  '12091': [Object],
  '12092': [Object],
  '12093': [Object],
  '12094': [Object],
  '12095': [Object],
  '12096': [Object],
  '12097': [Object],
  '12098': [Object],
  '12099': [Object],
  '12100': [Object],
  '12101': [Object],
  '12102': [Object]
},
'0x0000000A453D2De5Dd31Be7Bce57D5550a9CF964': { '16': [Object] },
'0x0000000Ae22EDb6fa815aBF4F32E4d4c3CD4944A': { '11': [Object] },
'0x0000000Ba1365f06809Ebc4A9086913696810268': { '19': [Object] },
'0x0000000FA550De25e3AEBE8CB0f06a803CEE8f81': { '16': [Object] },
.........

So I'd like to divide above response into each transactions.
Transactions issued from the same address also want to be split into each transaction.

For example, I've tried a following code.

let res = await txPool.getContent();
let adrOfKey = Object.keys(res.pending);

console.log(res.pending[adrOfKey[0]]);

This code can get a transaction. Like

  {
  '43': {
    blockHash: null,
    blockNumber: null,
    from: '0x000000057c695b6af389ff5b7542c7e01333981a',
    gas: '0x2a54f3',
    gasPrice: '0x3b0fb351',
    hash: '0x4ab292e6bf9b87df4e36d49c4f1f3a3b78a94c8cce2231f8391fcce838e0867c',
    input: '0xa0712d68000000000000000000000000000000000000000000000000000000000000004b',
    nonce: '0x2b',
    to: '0x0000000000b3f879cb30fe243b4dfee438691c04',
    transactionIndex: null,
    value: '0x0',
    v: '0x26',
    r: '0xfdf317f738171c5ff13c72ddc6457309abe99b711e428afa74789daf7e985f07',
    s: '0x7564970af16d59d6593b7c73f8222fc3aca55675df336036d1703a097bec63d3'
  }
 }

However, this cannot tell if there are any other transactions issued by the same address.

I've tried to using several function such as json.parse, map, forEach and some libraries such as underscore.js, lodash.js.

But I couldn't get the transaction.

My development environment is as follows:

IDE: IntelliJ(2019.3.3)
node.js: ver 13.6
web3.js: ver 2.0.0-alpha.1
web3-eth-txpool: 1.0.0-beta.55
geth: ver 1.9.11-stable

0

Change this:

console.log(res.pending[adrOfKey[0]]);

To this:

for (const key of adrOfKey)
    console.log(res.pending[key]);
| improve this answer | |
  • I've done. Thank you. – Pierogi Mar 23 at 0:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.