[英]How to get pending transactions in ethereum using web3?
我需要在以太web3
中使用web3
计算连续交易的现时数,但getTransactionCount
不会返回未决交易。
有没有一种方法可以使用web3
获取所有交易,包括未决交易和已完成交易? 如果不是web3
,还有其他方法吗?
这是一个已知的问题# 1741 ,也许您可以更好地等待交易被清除。
您尝试使用web3.eth.filter吗?
下面的代码应该工作。 (目前无法测试自己)
var options = {
fromBlock: "pending",
toBlock: "latest",
address: "0xabc123...",
}
web3.eth.filter(options, (error, result) => {
if (!error)
console.log(result);
});
使用web3js 1.0可以使用getPendingTransactions
web3.eth.getPendingTransactions().then(console.log);
> [
{
hash: '0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b',
nonce: 2,
blockHash: '0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46',
blockNumber: 3,
transactionIndex: 0,
from: '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b',
to: '0x6295ee1b4f6dd65047762f924ecd367c17eabf8f',
value: '123450000000000000',
gas: 314159,
gasPrice: '2000000000000',
input: '0x57cb2fc4'
v: '0x3d',
r: '0xaabc9ddafffb2ae0bac4107697547d22d9383667d9e97f5409dd6881ce08f13f',
s: '0x69e43116be8f842dcd4a0b2f760043737a59534430b762317db21d9ac8c5034'
},....,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.