Web3.js adds the eth. getRawTransactionByHash (txhash) method step,
Eth_getRawTransactionByHash
Https://ethereum.stackexchange.com/questions/7473/get-raw-transaction-from-hash
There is an "uninitialized ented" 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. Under node_modules, find the types. d. ts file under web3.
Eth
Add methods to the class
getRawTransaction(hash: string, cb?: Callback<TransactionRaw>): Promise<TransactionRaw>
Add TransactionRaw Definition
export declare interface TransactionRaw { raw: string}
2. Under the node_modules project, find index. js in the web3-eth.
methods={}
Add Method
new Method({ name: 'getRawTransaction', call: 'eth_getRawTransactionByHash', params: 1, inputFormatter: [null], outputFormatter: formatter.outputTransactionRawFormatter }),
3. Under the node_modules project, find formatters. js in the web3-core-helpers.
Add outputTransactionRawFormatter and add the corresponding 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};
Note: The above code is of version 1. 0.
Summary
The above section describes how to add eth to web3.js. the getRawTransactionByHash (txhash) method step is helpful to you. If you have any questions, please leave a message and the editor will reply to you in time. Thank you very much for your support for the help House website!