Using web3, how can you get the Tx cost and data/payload for a given transaction?

getTransaction(tx#) returns everything but those 2 values. This information seems to be available via blockchain explorers such as etherchain.org


web3.eth.getTransaction has an input property, which is the /payload for a given transaction.

The cost of a transaction is gasUsed multiplied by gasPrice.
web3.eth.getTransactionReceipt has the gasUsed property. web3.eth.getTransaction has gasPrice. Since the unit for gasPrice is wei, divide by 1e18 to get the Ether cost of a transaction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.