NomicFoundation / hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
https://hardhat.org
Other
7.33k stars 1.42k forks source link

Hardhat-ledger plugin error using blockchains that don't support EIP-1559 transaction format #5786

Open daveroga opened 2 months ago

daveroga commented 2 months ago

Version of Hardhat

2.22.10

What happened?

Trying to deploy smart contracts through hardhat and hardhat-ledger plugin (1.0.3) to Polygon zkEVM networks (Cardona or Mainnet) is not possible because it throws an error when trying to send signed transaction with eth_sendRawTransaction and EIP-1559 format.

{"jsonrpc":"2.0","id":17,"error":{"code":-32000,"message":"RPC error response: error getting from address"}}

Debugging it I see that is sending the transaction with type EIP-1559 that is not supported by zkEVM now (https://support.polygon.technology/support/solutions/articles/82000897869-does-polygon-zkevm-support-the-eip-1559-format-for-transactions-).

{
  "chainId": "2442",
  "type": "EIP-1559",
  ...
}

So at this moment to support deploying to Polygon zkEVM networks this ledger-plugin should send legacy transaction (type=0) instead and calcultaing then gasPrice. This will produce legacy transaction format:

{
  "chainId": "2442",
  "type": "LegacyTransaction",
  ...
}

Minimal reproduction steps

  1. Install hardhat-ledger plugin following the instructions here https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-ledger
  2. Patch first getting accounts in hardhat-ledger provider for zkEVM networks with empty array [] because eth_accounts is not supported in zkEVM node now (https://github.com/NomicFoundation/hardhat/issues/5785).
  3. Try to deploy a smart contract to zkEVM Cardona with some faucet through ledgerAccounts address with any Ledger device.

Search terms

hardhat-ledger zkevm eip-1559 eth_sendRawTransaction

kanej commented 1 month ago

Thanks for the reproduction steps we will take a look.