ethers.js icon indicating copy to clipboard operation
ethers.js copied to clipboard

zkSync Era Testnet : 'invalid value for value.blockHash' when waiting for tx confirmation

Open feloot opened this issue 3 years ago • 9 comments

Ethers Version

6.2.3

Search Terms

invalid value for value.blockHash

Describe the Problem

I'm trying to add support for zkSync Era Testnet on my dapp, but I'm unable to wait for transaction confirmations. I've tried:

await transactionResponse.wait()

and :

await provider.waitForTransaction(transactionResponse.hash, 1, 150000)

But both throw an error. I've included an example with token spending approval.

Code Snippet

const contractAddress = "0x20b28B1e4665FFf290650586ad76E977EAb90c5D" // WETH
const contractAbi = "..."
const provider = await stores.wallet.getProvider()
const signer = await provider.getSigner()

const wethContract = new ethers.Contract(
  contractAddress,
  contractAbi,
  provider
)
const wethContractConn = wethContract.connect(signer) as any

const transactionResponse = await wethContractConn.approve(
  contractAddress,
  BigInt(10)
)

const receipt = await transactionResponse.wait()

Contract ABI

Not included to ensure readability of the issue but for this example the ERC20 ABI will do.

Errors

EEE Error: invalid value for value.blockHash (invalid hash (argument="value", value=null, code=INVALID_ARGUMENT, version=6.2.3)) (value={ "blockHash": null, "blockNumber": null, "contractAddress": null, "cumulativeGasUsed": "0x0", "effectiveGasPrice": "0x0", "from": "0x9e3b4547adz9ad88a85f9cd7d6bcabcc413501f6", "gasUsed": "0x16fdc3", "l1BatchNumber": null, "l1BatchTxIndex": null, "l2ToL1Logs": [  ], "logs": [  ], "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "root": null, "status": null, "to": "0x20b28b1e4665fff290650586ad76e977eab90c5d", "transactionHash": "0xdea8a75627cffe6dd14b84150d03affcf4ca88cf10464086509cc6b0ca9e3ac9", "transactionIndex": "0x0", "type": "0x2" }, code=BAD_DATA, version=6.2.3)
    at makeError (errors.ts:663:21)
    at assert (errors.ts:680:25)
    at format.ts:58:17
    at formatTransactionReceipt (format.ts:179:12)
    at BrowserProvider._wrapTransactionReceipt (abstract-provider.ts:491:39)
    at BrowserProvider.getTransactionReceipt (abstract-provider.ts:928:21)
    at async listener (abstract-provider.ts:1024:37)

Environment

Browser (Chrome, Safari, etc)

Environment (Other)

Metamask on Chrome

feloot avatar Mar 28 '23 22:03 feloot

It looks like the hash was null. Can you include more information on the provider? I'll reach out to zkSync too, since that is one of my favourite projects, I want to make sure things work with them. :)

ricmoo avatar Mar 28 '23 23:03 ricmoo

I'm using Metamask on Google Chrome and my network settings are the following : Name : zkSync Era Testnet RPC : https://testnet.era.zksync.dev ChainId : 280 Symbol : ETH Explorer : https://goerli.explorer.zksync.io/

I'm not sure what information to include so let me know if you need anything specific, but normally it should be easy to reproduce.

Thanks !

feloot avatar Mar 29 '23 08:03 feloot

I got in touch with zkSync and they confirmed ethersjs v6 is not supported yet. They actually mention it in the following changelog : https://era.zksync.io/docs/dev/troubleshooting/changelog.html#system-update-v1-3-feb-8th-2023

image

Any ETA on the issue ? I've got a whole protocol ready for deployment :)

feloot avatar Apr 05 '23 11:04 feloot

Can you get them to reach out to me? I’m trying to find projects that need extra help migrating.

As far as I know, there shouldn’t be an issue, so I’m curious what it is…

ricmoo avatar Apr 05 '23 15:04 ricmoo

Hey @ricmoo @feloot! zkSync core dev here.

We're almost ready with our migration to v6, there're a few things that we have to finish first before rolling this out. Should be a few weeks tops. We will make sure to announce when it's released.

Just FYI @feloot please use the official zksync-web3 SDK (with ethers-v5 for now) to interact with Era, unless you know what you're doing and prepared to face errors like these :)

ly0va avatar Apr 06 '23 12:04 ly0va

@ly0va Awesome! Please reach out to me if you need anything or I can help, via E-mail, Twitter or discord. I love zkSync. :)

ricmoo avatar Apr 06 '23 12:04 ricmoo

Thanks @ly0va ! I wish we could use the zksync-web3 package, but we're using ethers v6 everywhere in our app now and we're already live on Ethereum, Arbitrum and zkEVM so it doesn't really make sense for us to migrate everything back and forth just for a few weeks.

We'll have to wait and I'll follow the announcements closely. We're really looking forward to bringing our TVL to Era, our userbase is asking us about it daily :)

Let me know if you need anything from me as well, I'd be glad to help.

feloot avatar Apr 06 '23 13:04 feloot

Hey @ricmoo @feloot! zkSync core dev here.

We're almost ready with our migration to v6, there're a few things that we have to finish first before rolling this out. Should be a few weeks tops. We will make sure to announce when it's released.

Just FYI @feloot please use the official zksync-web3 SDK (with ethers-v5 for now) to interact with Era, unless you know what you're doing and prepared to face errors like these :)

Are there any updates on migration?

T1murKO avatar Aug 12 '23 15:08 T1murKO

"ethers": "^6.7.1" is here, have the same issue @ricmoo @ly0va are there any updates you cat share with us?

Soniachniy avatar Sep 15 '23 11:09 Soniachniy

Hi, the same issue with 6.8.1.

When waitForTransaction is called too fast, there is null hash returned. It's sufficient to slightly wait (in debugger or via some kind of sleep) and everything works fine.

rickball avatar Nov 20 '23 13:11 rickball