.netethereumnethereum

How to resolve EIP version conflict between network and client?


I started the local Hardhat network (for testing smart contracts), connected to it using Nethereum, and when I try to start any transaction, the exception ChainId required for TransactionType 0X02 EIP1559 is thrown. Then I changed the network to Ganache, but the error remained the same. For example (F# code):

open System

type Account = 
    { Address : string
      PrivateKey: string }

[<EntryPoint>]
let main argv =
    
    let accounts =
        [| { Address = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"; PrivateKey = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" }
           { Address = "0x70997970c51812dc3a010c7d01b50e0d17dc79c8"; PrivateKey = "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d" } 
           { Address = "0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc"; PrivateKey = "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a" } |]
        |> Seq.map (fun a -> Nethereum.Web3.Accounts.Account(a.PrivateKey))
    
    let client = Seq.head accounts
    
    let web3 = new Nethereum.Web3.Web3(client, "http://localhost:8545")
    web3.Eth.Accounts.SendRequestAsync().Result // This works currectly
    |> Seq.iter (fun a -> printfn "%s" a) // and prints all network addresses
    let tx = web3.Eth.GetEtherTransferService().TransferEtherAndWaitForReceiptAsync("0x70997970c51812dc3a010c7d01b50e0d17dc79c8", 10m).Result // Here throws exception: localhost:8545 ChainId required for TransactionType 0X02 EIP1559)
    let balance = web3.Eth.GetBalance.SendRequestAsync("0x70997970c51812dc3a010c7d01b50e0d17dc79c8").Result
    0

I think I should wait until the Nethereum developers implement the support of EIP-1559 because there are no alternatives in the .NET world. Is it possible to somehow disable this requirement for transactions, or change the version of the actual standard? I didn't find a similar function in the Hardhat and Ganache documentation, but maybe there are networks for developers who have this function?


Solution

  • The solution is pretty simple: I needed to specify the ChainId when creating an account. For Hardhat, this value is 31337.