建议和反馈

请填写你的反馈内容

感谢您对链客的信任!

恭喜您填写完个人简历!链客专注于区块链职位连接,帮助您的投递更加精准高效,赶快去选择自己心仪的岗位吧!

推动中国区块链事业发展始终是我们坚定不移的梦——链客团队

问答 > 公有链 > 问答详情

一个交易怎么看他在哪个区块?

一个交易怎么看他在哪个区块?

链客

2019-03-14

3147

0

撰写答案

请先登陆或注册

5个回答

naruto

2019-03-14

你试试eth_getTransactionByHash

0
赞赏(0)

firesWU

2019-03-14

目前 EOS 中交易和区块的映射,如果是没有任何特殊化处理, 只有 blocks -> trx 的映射,没有 trx -> blocks 的映射。 而目前 history_plugin 虽然有做 trx -> block 的映射,但是其所耗内存和磁盘太多, 而且维护太麻烦。 目前 mongodb 是官方推荐的持久化方案。 但如果你不需要经常查, 可以用浏览器的 API 去获取。

0
赞赏(0)

三地

2019-03-14

eth_getTransactionByHash

0
赞赏(0)

德玛西亚

2019-03-14

每笔交易都会有一个hash, 比如0x314da1741ed41dcf112804f15b5432976d230ddb5544e652881108a8c4d8dfc1

> eth.getTransaction('0x314da1741ed41dcf112804f15b5432976d230ddb5544e652881108a8c4d8dfc1'){
  blockHash: "0x7de0c6cf94c8c1e21811fd72a0a8d9f74b5a365f11127f0ca084355fa5f2ff0c",
  blockNumber: 4,
  from: "0xb272c02ef7318b2274c7c45df7d02ce8d5f5c7ea",
  gas: 1000000,
  gasPrice: 21146972608,
  hash: "0x314da1741ed41dcf112804f15b5432976d230ddb5544e652881108a8c4d8dfc1",
  input: "0x606060405260405161026938038061026983398101604052805101600080546c0100000000000000000000000033810204600160a060020a03199091161790558060016000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1060b357805160ff19168380011785555b5060a29291505b8082111560e057600081556001016090565b505050610185806100e46000396000f35b828001600101855582156089579182015b82811115608957825182600050559160200191906001019060c4565b509056606060405260e060020a600035046341c0e1b58114610029578063cfae321714610070575b610002565b34610002576100de6000543373ffffffffffffffffffffffffffffffffffffffff9081169116141561014e5760005473ffffffffffffffffffffffffffffffffffffffff16ff5b3461000257604080516020808201835260008252600180548451600282841615610100026000190190921691909104601f81018490048402820184019095528481526100e094909283018282801561017b5780601f106101505761010080835404028352916020019161017b565b005b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156101405780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b565b820191906000526020600020905b81548152906001019060200180831161015e57829003601f168201915b5050505050905090560000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c48656c6c6f20576f726c64210000000000000000000000000000000000000000",
  nonce: 0,
  r: "0xa2f0f029963c0c9fa6ce98a97cf099ce34f08cda0aa710564a038f2261e536b4",
  s: "0x28816fca34cc0f5a129c46ec60794ca82030319c0504c253e8f09dab1b169dba",
  to: null,
  transactionIndex: 0,
  v: "0x1b",
  value: 0}

上面 blockNumber: 4 就是这笔交易所属的区块


0
赞赏(0)

sf快递

2019-03-14

eth_getTransactionByHash 这个RPC命令应该就可以吧

// Requestcurl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],"id":1}'// Result{"id":1,"jsonrpc":"2.0","result": {
    "hash":"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b",
    "nonce":"0x",
    "blockHash": "0xbeab0aa2411b7ab17f30a99d3cb9c6ef2fc5426d6ad6fd9e2a26a6aed1d1055b",
    "blockNumber": "0x15df", // 5599
    "transactionIndex":  "0x1", // 1
    "from":"0x407d73d8a49eeb85d32cf465507dd71d507100c1",
    "to":"0x85h43d8a49eeb85d32cf465507dd71d507100c1",
    "value":"0x7f110" // 520464
    "gas": "0x7f110" // 520464
    "gasPrice":"0x09184e72a000",
    "input":"0x603880600c6000396000f300603880600c6000396000f3603880600c6000396000f360",
  }}


0
赞赏(0)
邀请

感谢您的善举,每一次解答会成为新人的灯塔,回答被采纳后获得20算力和相应的LK币奖励