Mahsum Akbas
Mahsum Akbas

Reputation: 1583

Geth "invalid argument 0: json: cannot unmarshal non-string into Go value of type common.Address" error

I run following request to Geth:

POST http://localhost:8545

{
"jsonrpc":"2.0",
"id":1,
"method": "eth_sign",
  "params": [
    {
      "from": "0xDc89096c0E279933a7C99e13f1474A0a84320207",
      "gas": "0x55555",
      "maxFeePerGas": "0x1234",
      "maxPriorityFeePerGas": "0x1234",
      "input": "",
      "nonce": "0x0",
      "to": "0xCdde93eEDC6c911D33E7fe41DC05208E0630a4c0",
      "value": "0x1234"
    }
  ]
}

but getting following error:

{
    "jsonrpc": "2.0",
    "id": 1,
    "error": {
        "code": -32602,
        "message": "invalid argument 0: json: cannot unmarshal non-string into Go value of type common.Address"
    }
}

Geth Version: Geth/v1.10.26-stable-e5eb32ac/windows-amd64/go1.18.5

What can be reason?

Upvotes: 0

Views: 1539

Answers (1)

Petr Hejda
Petr Hejda

Reputation: 43561

eth_sign is meant for signing arbitrary messages - not transactions - and takes 2 params:

  1. Address of the signer. It assumes that the signer has an unlocked account on the node (i.e. the node knows the private key that derives into this address).
  2. The message to sign

Based on the params that you're passing, it seems that you want to sign a transaction instead. For that, there's the eth_signTransaction method.

Again, it succeeds only if the node knows the private key to the from address, and the account holding the private key is unlocked on the node.

Upvotes: 1

Related Questions