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

eth_estimate_gas always return web3.exceptions.ContractLogicError: execution reverted: Failed to submit transaction: cannot estimate gas #26

Closed
seaify opened this issue May 9, 2023 · 4 comments

Comments

@seaify
Copy link

seaify commented May 9, 2023

       account: LocalAccount = Account.from_key(self.private_key)

        # Get chain id of zkSync network
        chain_id = self.web3.zksync.chain_id

        # Signer is used to generate signature of provided transaction
        signer = PrivateKeyEthSigner(account, chain_id)

        # Get nonce of ETH address on zkSync network
        nonce = self.web3.zksync.get_transaction_count(
            account.address, ZkBlockParams.COMMITTED.value
        )

        # Get current gas price in Wei
        gas_price = self.web3.zksync.gas_price

        # Create transaction
        tx_func_call = TxFunctionCall(
            chain_id=chain_id,
            nonce=nonce,
            from_=account.address,
            to=to_checksum_address(to_address),
            value=self.web3.to_wei(amount, "ether"),
            data=HexStr("0x8722b9f70000000000000000000000000000000000000000000000000000000000000001"),
            gas_limit=10000000,  # UNKNOWN AT THIS STATE
            gas_price=gas_price,
            max_priority_fee_per_gas=100000000,
        )

        # ZkSync transaction gas estimation
        estimate_gas = self.web3.zksync.eth_estimate_gas(tx_func_call.tx)
        print(f"Fee for transaction is: {estimate_gas * gas_price}")

        # Convert transaction to EIP-712 format
        tx_712 = tx_func_call.tx712(estimate_gas)

        # Sign message & encode it
        signed_message = signer.sign_typed_data(tx_712.to_eip712_struct())

        # Encode signed message
        msg = tx_712.encode(signed_message)

        # Transfer ETH
        tx_hash = self.web3.zksync.send_raw_transaction(msg)
        print(f"Transaction hash is : {tx_hash.hex()}")

the error message is weird, i have enough eth in my wallet for gas use

@danijelTxFusion
Copy link
Contributor

danijelTxFusion commented May 10, 2023

This is problem to the ZkSync network: eth_call was not fully compatible with common dev tools used in L1. Because of that errors like cannot estimate gas occurs. This bug is fixed and ZkSync nodes are patched on testnet, so this should no longer be an issue on testnet.

@lusharenck
Copy link

This is problem to the ZkSync network: eth_call was not fully compatible with common dev tools used in L1. Because of that errors like cannot estimate gas occurs. This bug is fixed and ZkSync nodes are patched on testnet, so this should no longer be an issue on testnet.

still have this problem
I am using zk mainnet
image

@danijelTxFusion
Copy link
Contributor

This is still an issue on mainnet. Don't forget that mainnet is in alpha state and some issues may occur.

@lusharenck
Copy link

This is still an issue on mainnet. Don't forget that mainnet is in alpha state and some issues may occur.

OK, thanks. But this problem did not occur before, I hope the zksync team can fix this important function as soon as possible

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

3 participants