question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getTransactionReceipt error

See original GitHub issue
await provider.waitForTransaction(transaction.hash);
const receipt = await provider.getTransactionReceipt(transaction.hash);

When I log receipt from getTransactionReceipt, I get this error:

Error: invalid transaction receipt - exactly one of status and root should be present

What am I doing wrong?

My provider is a parity node running on Kovan (I used providers.JsonRpcProvider)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
ricmoocommented, Jul 25, 2018

If you use v4, interface.parseLog will figure out which event it is and parse it for you, including the name, function signature, topic and parsed values.

There is also an interface.parseTransaction that will look up what function and what values the transaction represents.

So, you can directly access contract.interface.parseLog if you have a contract, or you can just instantiate an Interface if you are processing the blockchain in general.

0reactions
naddison36commented, Jul 25, 2018

@mrwillis this is how I parse events in the transactions receipt.

/**
 * Parses transaction events from the logs in a transaction receipt
 * @param {TransactionReceipt} receipt Transaction receipt containing the events in the logs
 * @returns {{[eventName: string]: TransactionEvent}} an object with each key-value pair being the event name and event object
 */
protected getTransactionEvents(receipt: TransactionReceipt): {[eventName: string]: TransactionEvent}
{
	const txEvents: {[eventName: string]: TransactionEvent}  = {}

	// do not get events if the contract has not been set yet. This will be true for deploy transactions which can emit events
	if (!this.contract) {
		return txEvents
	}

	// for each log in the transaction receipt
	for (const log of receipt.logs)
	{
		// for each event in the ABI
		for (const abiEvent of Object.values(this.contract.interface.events))
		{
			// if the hash of the ABI event equals the tx receipt log
			if (abiEvent.topics[0] == log.topics[0])
			{
				// Parse the event from the log topics and data
				txEvents[abiEvent.name] = abiEvent.parse(log.topics, log.data)

				// stop looping through the ABI events
				break
			}
		}
	}

	return txEvents
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

eth_getTransactionReceipt - Alchemy Docs
Returns the receipt of a transaction by transaction hash. Don't have an API key? Start using this API in your app today.
Read more >
How to get transaction failed reason with transaction hash with ...
I'm trying to get transaction failed reason with transaction hash with web3? I have checked getTransactionReceipt() method
Read more >
jsonrpc - Go Packages
GetTransactionReceipt returns the receipt of a transaction by transaction hash. func (*Eth) NewBlockFilter ¶. func (e *Eth) NewBlockFilter() ( ...
Read more >
ethereum/web3.py - Gitter
getTransactionReceipt (result) error: File "C:\Users\Eric\AppData\Local\Programs\Python\Python37\lib\site-packages\web3\eth.py", line 274, ...
Read more >
web3.eth — web3.js 1.0.0 documentation
Incorrect checksum addresses will throw an error when passed into functions. If you want to circumvent the ... getTransactionReceipt(hash [, callback]).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found