V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
d284476422
V2EX  ›  程序员

请教下, GAS 中的 Gas Used By Txn 怎么获取?

  •  1
     
  •   d284476422 · 2018-04-18 19:47:55 +08:00 · 2168 次点击
    这是一个创建于 2171 天前的主题,其中的信息可能已经有所发展或是发生改变。

    通过 ethGetTransactionByHash 方法查询出订单,获取到了 Gas Limit 和 gasPrice,但是 Gas Used By Txn 怎么获取,需要 Gas Used By Txn * gasPrice。 下面是返回的数据,删除了 hash。

    { "gasRaw": "0x927c0", "blockHash": "0x7a344994dbc25f6d17d6974522b650937e6f4c2d0eae1785f5e93a67565e611e", "transactionIndexRaw": "0x3", "valueRaw": "0x2c68af0bb140000", "raw": "0xf86b08830186a0830927c0942a23e12acef43b964857b66cde6de2d674601e7b8802c68af0bb140000801ba00c7cae6b2f6848a78ff6da9e295873b4891e04345e0b67fe4c48e4a41e1992d5a035a64c7e6c776d3f0aaf986eac73e50b5f310b7a3e7c8d799add877064a03d32", "transactionIndex": 3, "publicKey": "0xdee62c1c569dc6eec06a59e3b34c7e1f03712d83c42717a717e6d7bd39ac06e07234b89cb973387311eeb0666a60d35cba957932bbd4d17644e9212effa5ff09", "nonce": 8, "gasPriceRaw": "0x186a0", "input": "0x", "r": "0xc7cae6b2f6848a78ff6da9e295873b4891e04345e0b67fe4c48e4a41e1992d5", "blockNumberRaw": "0x696f5f", "s": "0x35a64c7e6c776d3f0aaf986eac73e50b5f310b7a3e7c8d799add877064a03d32", "nonceRaw": "0x8", "v": 27, "blockNumber": 6909791, "gas": 600000, "from": "0xad8bd961e9792fa7deeef7dd623db5f54b24efdd", "to": "0x2a23e12acef43b964857b66cde6de2d674601e7b", "value": 200000000000000000, "gasPrice": 100000 }

    第 1 条附言  ·  2018-04-18 22:22:48 +08:00
    关于消耗的数量
    1.转账返回会有"gasUsed": 21000,返回
    2.web3.ethGetTransactionReceipt("hash") 会返回 gasUsed

    但是时间还是不知道。
    d284476422
        1
    d284476422  
    OP
       2018-04-18 19:48:40 +08:00
    有木有大神,来回答下
    aptx4689
        2
    aptx4689  
       2018-04-19 10:04:27 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1545 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 23:59 · PVG 07:59 · LAX 16:59 · JFK 19:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.