Web3.js adds the eth. getRawTransactionByHash (txhash) method step,

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.