web3.js增加eth.getRawTransactionByHash(txhash)方法步驟
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.項(xiàng)目node_modules 下找到web3 下types.d.ts文件
Eth
類中增加方法
getRawTransaction(hash: string, cb?: Callback<TransactionRaw>): Promise<TransactionRaw>
增加TransactionRaw定義
export declare interface TransactionRaw { raw: string }
2.項(xiàng)目node_modules 下找到 web3-eth中 index.js
methods={}
增加方法
new Method({ name: 'getRawTransaction', call: 'eth_getRawTransactionByHash', params: 1, inputFormatter: [null], outputFormatter: formatter.outputTransactionRawFormatter }),
3.項(xiàng)目node_modules 下找到 web3-core-helpers中 formatters.js
增加 outputTransactionRawFormatter并module.exports中也增加對(duì)應(yīng)
/** * 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.版本的
總結(jié)
以上所述是小編給大家介紹的web3.js增加eth.getRawTransactionByHash(txhash)方法步驟,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
URL的參數(shù)中有加號(hào)傳值變?yōu)榭崭竦膯?wèn)題(URL特殊字符)
今天在調(diào)試客戶端向服務(wù)器傳遞參數(shù)時(shí),參數(shù)中的“+”全部變成了空格,原因是URL中默認(rèn)的將“+”號(hào)轉(zhuǎn)義了,經(jīng)過(guò)以下步驟解決了,需要的朋友可以參考一下2016-11-11JS中使用gulp實(shí)現(xiàn)壓縮文件及瀏覽器熱加載功能
這篇文章主要介紹了JS中使用gulp實(shí)現(xiàn)壓縮文件及瀏覽器熱加載功能,需要的朋友可以參考下2017-07-07Javascript iframe交互并兼容各種瀏覽器的解決方法
這篇文章主要介紹了Javascript iframe交互并兼容各種瀏覽器的解決方法的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-07-07javascript跑馬燈抽獎(jiǎng)實(shí)例講解
這篇文章主要為大家介紹了javascript跑馬燈抽獎(jiǎng)特效,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-01-01前端實(shí)現(xiàn)word文檔預(yù)覽和內(nèi)容提取的詳細(xì)過(guò)程
在前端直接讀取并原樣展示W(wǎng)ord文檔是一個(gè)相對(duì)復(fù)雜的任務(wù),因?yàn)閃ord文檔的格式(如.doc或.docx)與Web技術(shù)棧使用的格式(HTML、CSS)不兼容,下面這篇文章主要給大家介紹了關(guān)于前端實(shí)現(xiàn)word文檔預(yù)覽和內(nèi)容提取的詳細(xì)過(guò)程,需要的朋友可以參考下2024-05-05javascript制作坦克大戰(zhàn)全紀(jì)錄(2)
上文我們簡(jiǎn)單的完成了坦克大戰(zhàn)的雛形,本文我們來(lái)繼續(xù)完善坦克大戰(zhàn),接下來(lái)我們來(lái)學(xué)習(xí)制作地圖和碰撞檢測(cè)方面的問(wèn)題。2014-11-11基于Arcgis for javascript實(shí)現(xiàn)百度地圖ABCD marker的效果
本篇文章由腳本之家小編給大家分享的基于Arcgis for javascript實(shí)現(xiàn)百度地圖ABCD marker的效果,需要的朋友一起學(xué)習(xí)吧2015-09-09