相思资源网 Design By www.200059.com

eth_getRawTransactionByHash

https://ethereum.stackexchange.com/questions/7473/get-raw-transaction-from-hash

There is an "undocumented" method eth_getRawTransactionByHash from JSON-RPC

curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_getRawTransactionByHash","params":["<TX_HASH>"],"id":1}' http://localhost:8545
<TX_HASH> - transaction id

1.项目node_modules 下找到web3  下types.d.ts文件

Eth

   类中增加方法

 getRawTransaction(hash: string, cb"htmlcode">
export declare interface TransactionRaw {
 raw: string
}

2.项目node_modules 下找到 web3-eth中   index.js

methods={}

增加方法

new Method({
   name: 'getRawTransaction',
   call: 'eth_getRawTransactionByHash',
   params: 1,
   inputFormatter: [null],
   outputFormatter: formatter.outputTransactionRawFormatter
  }),

3.项目node_modules 下找到 web3-core-helpers中  formatters.js

增加 outputTransactionRawFormatter并module.exports中也增加对应

/**
 * Formats the output of a transaction raw value
 *
 * @method outputTransactionRawFormatter
 * @param {Object} tx
 * @returns {Object}
*/
var outputTransactionRawFormatter = function (tx){
 return tx;
};
module.exports = {
 inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,
 inputBlockNumberFormatter: inputBlockNumberFormatter,
 inputCallFormatter: inputCallFormatter,
 inputTransactionFormatter: inputTransactionFormatter,
 inputAddressFormatter: inputAddressFormatter,
 inputPostFormatter: inputPostFormatter,
 inputLogFormatter: inputLogFormatter,
 inputSignFormatter: inputSignFormatter,
 outputBigNumberFormatter: outputBigNumberFormatter,
 outputTransactionFormatter: outputTransactionFormatter,
 outputTransactionRawFormatter: outputTransactionRawFormatter,
 outputTransactionReceiptFormatter: outputTransactionReceiptFormatter,
 outputBlockFormatter: outputBlockFormatter,
 outputLogFormatter: outputLogFormatter,
 outputPostFormatter: outputPostFormatter,
 outputSyncingFormatter: outputSyncingFormatter
};

备注:以上代码是1.0.版本的

总结

以上所述是小编给大家介绍的web3.js增加eth.getRawTransactionByHash(txhash)方法步骤,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!

标签:
web3.js,eth.getRawTransactionByHash,web3j.ethgetbalance

相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com

评论“web3.js增加eth.getRawTransactionByHash(txhash)方法步骤”

暂无web3.js增加eth.getRawTransactionByHash(txhash)方法步骤的评论...