Go-Ethereum

PoA 專用網路上的 web3 出現“無效發件人”錯誤

  • March 17, 2022

我正在使用 web3 簽署以下交易並使用 sendSignedTransaction 將其發送到節點。但是我不斷收到“無效發件人”錯誤。

我在 genesis.json 中將網路 ID 設置為 6454,並且節點以相同的網路 ID 啟動。我也用它來簽署交易。

{
"to": "0x609be532b4411da754c55295f9a067819d2b563c",
"value": "0xff",
"gas": "0x61a8",
"gasPrice": "0x1e8f1c10800",
"from": "0x55eb76b1d8ff63ffbe211913a7f91a17cb98063c",
"nonce": "0x0",
"chainId": 6454,
"data": ""

}

編輯; 這是我的 genesis.json

{
"config": {
   "chainId": 6454,
   "homesteadBlock": 1,
   "eip150Block": 2,
   "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
   "eip155Block": 3,
   "eip158Block": 3,
   "byzantiumBlock": 4,
   "clique": {
   "period": 1,
   "epoch": 30000
   }
},
"nonce": "0x0",
"timestamp": "0x5b33af98",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000240ebbd4e36bce0071994d62c78319d028fb651bac65b46b5c6257bd7c790fa51eb54d9f68f559d20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
   "240ebbd4e36bce0071994d62c78319d028fb651b": {
   "balance": "0x500000000000000000000000000000000000000000000000000000000000000"
   },
   "ac65b46b5c6257bd7c790fa51eb54d9f68f559d2": {
   "balance": "0x500000000000000000000000000000000000000000000000000000000000000"
   }
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}

最可能的錯誤是你用錯了chainId,或者你的私鏈沒有配置EIP155區塊號。將 EIP155 塊號設置為 1 以解決此問題。此外,您用於發送交易的錢包必須啟用 EIP155。

否則,您必須調試您的簽名過程,因為您的問題沒有提供任何詳細資訊來做出更確定的猜測。

從來源:

// Make sure the transaction is signed properly
from, err := types.Sender(pool.signer, tx)
if err != nil {
   return ErrInvalidSender
}

要檢查的另一件事是您的 POA 節點是否使用 ssl,如果是,請在連接節點時提及基於 https 的 url。我遇到了同樣的問題,並且很長一段時間都在為鏈 ID 苦苦掙扎。然後最終檢查節點 url 是 https 而不是 http,它就像一個魅力

引用自:https://ethereum.stackexchange.com/questions/54546