网络与客户端EIP版本冲突如何解决?
How to resolve EIP version conflict between network and client?
我启动了本地 Hardhat 网络(用于测试智能合约),使用 Nethereum 连接到它,当我尝试启动任何交易时,抛出异常 ChainId required for TransactionType 0X02 EIP1559
。然后我把网络改成Ganache,还是报错。例如(F# 代码):
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
我想我应该等到 Nethereum 开发人员实现对 EIP-1559 的支持,因为在 .NET 世界中没有其他选择。是否有可能以某种方式禁用此交易要求,或更改实际标准的版本?我在Hardhat和Ganache的文档中没有找到类似的功能,但也许有开发者的网络有这个功能?
解决方法很简单:我需要在创建账户时指定ChainId。对于 Hardhat,此值为 31337。
我启动了本地 Hardhat 网络(用于测试智能合约),使用 Nethereum 连接到它,当我尝试启动任何交易时,抛出异常 ChainId required for TransactionType 0X02 EIP1559
。然后我把网络改成Ganache,还是报错。例如(F# 代码):
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
我想我应该等到 Nethereum 开发人员实现对 EIP-1559 的支持,因为在 .NET 世界中没有其他选择。是否有可能以某种方式禁用此交易要求,或更改实际标准的版本?我在Hardhat和Ganache的文档中没有找到类似的功能,但也许有开发者的网络有这个功能?
解决方法很简单:我需要在创建账户时指定ChainId。对于 Hardhat,此值为 31337。