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

useWriteContract attempts to create a contract if the address field contains an empty string #4502

Open
1 task done
briandoyle81 opened this issue Jan 10, 2025 · 0 comments

Comments

@briandoyle81
Copy link

Check existing issues

Describe the bug

I'm writing a demo app that saves ~128*128 images onchain as base64 encoded strings. It allows users to create several galleries. A frontend bug caused cases where the address field was an empty string. Instead of erroring, the tx is sent, which is interpreted by the EVM as an attempt to create a contract - data but no to address.

  function handleSaveOnchain() {
    setAwaitingResponse(true);
    writeContract({
      abi: personalImageGallery.abi,
      address: activeAddress as `0x${string}`,
      functionName: 'addImage',
      args: ['test', uploadedBase64Image],
    });
  }

Link to Minimal Reproducible Example

https://github.com/briandoyle81/image-gallery-fe/blob/3b7d43f1098ea87a86f276a7123fe928505f7947/app/components/Content.tsx

Steps To Reproduce

Clone and npm install repo.

You'll need a Flow wallet or any EVM wallet with about $0.01 (1 cent) of Flow in it.

On line 118 of Content.tsx, change to: address: '' as 0x${string},

Run the app

Sign in and complete the transaction to create a gallery.

Upload an image smaller than ~28 KB

Click Save Onchain

Watch the console and observe Content.tsx:54 CallExecutionError: Missing or invalid parameters. Double check you have provided the correct parameters. followed by net::ERR_CONNECTION_RESET 431 (Request Header Fields Too Large)

Open network and find one of the "eth_getTransactionByHash" calls and copy the tx hash.

Find on evm.flowscan.com and observe a failed attempt to create a transaction.

Similar to: https://evm.flowscan.io/tx/0xcc21f1bf6410c93122bdb71629b8783a8c00029233e546242b0b32ee63be01d1

What Wagmi package(s) are you using?

wagmi

Wagmi Package(s) Version(s)

^2.14.6

Viem Version

^2.22.3

TypeScript Version

^5

Anything else?

Flow is fully EVM equivalent, but it does have some differences compared to a standard network. It's very unlikely, but possible this impacts the bug.

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

No branches or pull requests

1 participant