[Ethereum] personal_signAndSendTransaction json: cannot unmarshal string into Go value of type eth.SendTxArgs

json-rpctransactions

Hoping you guys can help as I'm dead ended trying to SEND ether via rpc.
Before I jump off a tall building I will try stack exchange for the first time.

Error I get is:

PHP Fatal error:  Uncaught RPCException:  json: cannot unmarshal string into Go value of type eth.SendTxArgs

The Actual echoed json for SendTxARgs:

{"from":"0x549b968b43d503544854675387c5897a8a1c4f38","to":"0x7c9943A3C97099dBD6b1D6040d19D1Df4aB91de4","value":"0x58d15e17628000"}

which matches the args via api and docs as:

SendTxArgs struct {
    From     common.Address  `json:"from"`
    To       *common.Address `json:"to"`
    Gas      *rpc.HexNumber  `json:"gas"`
    GasPrice *rpc.HexNumber  `json:"gasPrice"`
    Value    *rpc.HexNumber  `json:"value"`
    Data     string          `json:"data"`
    Nonce    *rpc.HexNumber  `json:"nonce"`
}

actual code calling the send:

$jsontx = json_encode($tx);
echo $jsontx.PHP_EOL;
echo 'sending '.$ethereum->personal_signAndSendTransaction($jsontx,$pw).PHP_EOL;

Relying on function:

function personal_signAndSendTransaction($tx, $pw) {
    return $this->ether_request(__FUNCTION__, array($tx, $pw));
} 

Relying on a script that works for all other calls so far.. https://github.com/btelle/ethereum-php

Any gurus out there ?? help a brother out?

Best Answer

Found it the hard way guys. Just kept trying everything as the docs are NOT clear on the exact json format. Here is a working example:

{"id":"1",
 "method": "personal_signAndSendTransaction", 
 "params": [{"from": "0x549b955555555555555555551c4f38", 
   "to": "0x7c9943555555555555555aB91de4", 
   "value": "0x58d15e17628000"},
   "passphrase"]}

Cheerio!

Related Topic