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

Insufficient funds for gas * price + value"}, method="sendTransaction", transaction=undefined, code=INSUFFICIENT_FUNDS #653

Open
3 tasks done
phil3k3 opened this issue Oct 25, 2023 · 2 comments

Comments

@phil3k3
Copy link

phil3k3 commented Oct 25, 2023

โœ… Prerequisites

  • Did you perform a cursory search of open issues? Is this bug already reported elsewhere?
  • Are you running the latest SDK version?
  • Are you reporting to the correct repository (magic-sdk)?

๐Ÿ› Description

I am receiving INSUFFICIENT_FUNDS when trying to use the signer of Magic's RPC provider.

Magic RPC Error: [-32603] Error forwarded from node: insufficient funds for gas * price + value"}, method="sendTransaction", transaction=undefined, code=INSUFFICIENT_FUNDS

๐Ÿงฉ Steps to Reproduce

  1. Create sample project as described in https://magic.link/docs/dedicated/login-methods/email/integration/web
  2. Generate a Web3Provider using ethers v5
    const owner = new ethers.providers.Web3Provider(magic.rpcProvider as any);
  3. Use the signer of this provider to retrieve the balance of an ERC 20 token
const contract = new ethers.Contract(tokenAddress, erc20Abi, owner.getSigner());
const balance = await contract.balanceOf(receiver);

๐Ÿค” Expected behavior

Getting the balance of this usually gas-less transaction.

๐Ÿ˜ฎ Actual behavior

"Magic RPC Error: [-32603] Error forwarded from node: insufficient funds for gas * price + value"}, method="sendTransaction", transaction=undefined, code=INSUFFICIENT_FUNDS

๐Ÿ’ป Code Sample

[If possible, please provide a code repository, gist, code snippet or sample files to reproduce the issue.]

๐ŸŒŽ Environment

Software Version(s)
magic-sdk 21.0.0
Browser Chrome
yarn 1.22.19
Operating System MacOS 13.4.1
@am-hernandez
Copy link
Member

Hello @phil3k3 ,

The error you shared should throw when you attempt to send a transaction or interact with a smart contract but don't have enough native token balance to cover the cost of the interaction. It should not throw for a contract interaction that is just reading state, because there is no fee for reading the contract state.

Would you be able to provide a reproducible code sandbox where this issue is reproduced? If not, do you have steps for us to follow to reproduce this issue?

I created a sandbox here that makes a call to the Uniswap contract to get the balance of an account. The call properly returns even with a new user wallet because balanceOf is a view function and does not require gas. You may fork the demo to reproduce your issue.

Thank you,

@JosephLeva
Copy link

@phil3k3 did you ever find a way to send a transaction with gas using a magic wallet account? I am currently receiving the same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants