Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: TransactionExecutionError nativeCurrency undefined #1457

Closed
1 task done
technophile-04 opened this issue Oct 24, 2023 · 4 comments
Closed
1 task done

bug: TransactionExecutionError nativeCurrency undefined #1457

technophile-04 opened this issue Oct 24, 2023 · 4 comments

Comments

@technophile-04
Copy link

technophile-04 commented Oct 24, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Package Version

1.4.4

Current Behavior

This error happens when you try to send value and you don't have enough value in your wallet.

Screenshot 2023-10-24 at 3 18 46 PM

As we can see in above image the wallet has approx 2eth and trying to send 5th. The error thrown by viem is "Connot read properties of undefined (reading symbol)"

Expected Behavior

Ideally, the error should have been :

"sender doesn't have enough funds to send tx. The max upfront cost is: 5000066191091876292 and the sender's account only has: 1999803004163219134"

Steps To Reproduce

Please check the "Anything else?" section for a quick summary since I feel the error is obvious.....but here is how to reproduce it :
  1. Clone SE-2 repo
git clone https://github.com/scaffold-eth/scaffold-eth-2.git
cd scaffold-eth-2
git checkout ab6c9c3decceb961657fc9ddbdf7e0b56d6eb324
yarn install
  1. Run a local network in the first terminal:
yarn chain
  1. On a second terminal, deploy the test contract:
yarn deploy
  1. On a third terminal, start your NextJS app:
yarn start

After this just try to go to Debug tab and try setGreeting with a value that is greater than your wallet value

Link to Minimal Reproducible Example (StackBlitz, CodeSandbox, GitHub repo etc.)

https://github.com/scaffold-eth/scaffold-eth-2

Anything else?

Did some digging and it seems the problem is caused due to this line :

https://github.com/wagmi-dev/wagmi/blob/b12248167636e413ec2b6f477e3961b190468c04/packages/core/src/actions/contracts/writeContract.ts#L92

Here we can see if chainId is passed as args it makes chain as chain : {id : number}

And now if you check at TransactionExecutionError class from viem from it has :

Screenshot 2023-10-24 at 4 49 52 PM

checkout this line


Here are some SS from while debugging :
Screenshot 2023-10-24 at 4 28 42 PM

Checkout chain = {id : 31337} since it only have id property it throws while doing chain.nativeCurrencty.symbol

@1997roylee
Copy link

I tried to reproduce your issue from the repository, but nothing happened. The transaction was processed successfully.

@technophile-04
Copy link
Author

I tried to reproduce your issue from the repository, but nothing happened. The transaction was processed successfully.

Thanks for looking into it 🙌 Actually we removed chainId while using useContractWrite at scaffold-eth/scaffold-eth-2#584 and I forgot to update Reproduce steps (edited it now).

To reproduce just checkout to this commit scaffold-eth/scaffold-eth-2@ab6c9c3

i.e after git clone do git checkout ab6c9c3decceb961657fc9ddbdf7e0b56d6eb324 , updated the OG comment #1457 with same instruction

@tmm
Copy link
Member

tmm commented Nov 6, 2023

Transferring over to Viem

@tmm tmm transferred this issue from wevm/wagmi Nov 6, 2023
@tmm tmm changed the title bug: incorrect error when passing chainId to useContractWrite bug: TransactionExecutionError nativeCurrency undefined Nov 6, 2023
@jxom jxom closed this as completed in 4621390 Nov 7, 2023
Copy link
Contributor

This issue has been locked since it has been closed for more than 14 days.

If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Viem version. If you have any questions or comments you can create a new discussion thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants