10

I created a transaction in Go, signed it with a EIP155Signer signer, but when I try to publish the transaction through the Go client to the private blockchain, I get the error Invalid sender. Any idea what's happening here?

This issue seems to have the same error: https://github.com/ethereum/web3.js/issues/566

The transaction gets signed correctly (string output below), but the From field is never populated, and I'm unable to set it in Go because it's a hidden struct field that is internally set by the EIP155Signer

tx before sign=
    TX(e694193e2f4d6dc099444ff0057456e23cafe0f8035c7c70daf688bc2bf5546a)
    Contract: false
    From:     [invalid sender: invalid sig]
    To:       b424f3bcc3da6f54f27f5f4af0c9c18d567702e6
    Nonce:    0
    GasPrice: 0x0
    GasLimit  0x0
    Value:    0x0
    Data:     0x746865626573746461746165766572
    V:        0x0
    R:        0x0
    S:        0x0
    Hex:      ec80808094b424f3bcc3da6f54f27f5f4af0c9c18d567702e6808f746865626573746461746165766572808080

signed tx=
    TX(ff6c011c7527f74e00fde94f6a4a5e523211f21f221c0b7133bf723486b3284c)
    Contract: false
    From:     [invalid sender: invalid sig]
    To:       b424f3bcc3da6f54f27f5f4af0c9c18d567702e6
    Nonce:    0
    GasPrice: 0x0
    GasLimit  0x0
    Value:    0x0
    Data:     0x746865626573746461746165766572
    V:        0x0
    R:        0x91a89e1ee55cc959572c050780301701c7f02436701db5961ccb01d556c2e708
    S:        0x699559f036a1153b2f979cd01ee9b0beb0e889c8aaab0dbd5a46dd7931842f02
    Hex:      f86c80808094b424f3bcc3da6f54f27f5f4af0c9c18d567702e6808f74686562657374646174616576657280a091a89e1ee55cc959572c050780301701c7f02436701db5961ccb01d556c2e708a0699559f036a1153b2f979cd01ee9b0beb0e889c8aaab0dbd5a46dd7931842f02

Seems that the sender can't be derived according to this source file when the transaction is printed: https://github.com/ethereum/go-ethereum/blob/8771c3061f340451d0966adcc547338a25f2231f/core/types/transaction.go#L273

  • Figured this out earlier, will update – delos Mar 26 '17 at 4:10
  • 1
    Can you let us know how you solved this? :) – Richard Horrocks Apr 20 '17 at 21:36
  • @RichardHorrocks I'll write up an answer now – delos Apr 20 '17 at 22:00
15

The issue was that the chain id was not being set correctly. As a result transactions were signed with the incorrect chain id, so the sender could not be derived correctly. The fix was to also declare a config in the genesis block which specified it. An example:

"config": {
    "chainID"       : 10,
    "homesteadBlock": 0,
    "eip155Block":    0,
    "eip158Block":    0
}
  • 1
    How do you know what the right chainId should be? – zero_cool Apr 6 '18 at 0:33
  • You define the chain id, but some numbers are reserved. The chain id 1 for instance, is used by the Ethereum main net. – delos Apr 6 '18 at 1:03
  • 1
    ChainID 3 for Ropsten solved this for me. – zero_cool Apr 6 '18 at 1:35
0

before signing: rawTx.v = Buffer.from([chainId]) rawTx.nonce = web3.utils.toHex(web3.eth.getTransactionCount(account))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.